Binding, Functions and Control Flow - Reading Assignment

  1. A fragment of code that produces a value
  2. To catch and hold values
  3. A collection of bindings and their values that exist at a given time
  4. A function is a piece of program wrapped in a value
  5. alert (“enter passcode”);
  6. Showing a dialog box or writing text to the screen is a side effect
  7. alert (“enter passcode”);
    console.log (math.max (2, 4));
    // 102
  8. The direction of code which happens from top to bottom
  9. It’s where the program takes the proper branch based on the situation at hand
  10. if
1 Like

BINDING, FUNCTIONS AND CONTROL FLOW

  1. What is an expression?

Just a piece or part of a code that produces a value.

  1. What is a binding?

It is what makes the program remember previous declared variables.

  1. What is an environment?

It is basically an ecosystem where different bindings and their values coexist inside a program.

  1. What is a function?

It is a small tiny little program that lives inside the parentheses “()”.

  1. Give an example of a function.

Console.log(10 – 3)

  1. What is a side effect?

Showing a dialog box or writing text to the screen.

  1. Give an example of a function that produces a side effect and another function that produces a value.
  • Prompt()
  • Math.max()
  1. What is control flow?

Just a way to control the way expressions are being executed, starting from top to bottom.

  1. What is conditional execution?

Not all programs are straight roads. We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand.

  1. What kind of keyword do you need to use to invoke conditional execution?

“If”.

1 Like
  1. An expression is a piece of code that will output a result that is a value.

  2. Binding is creating variables, assigning symbolic keywords or phrases to contain a value.

  3. An environment refers to the entirety of every variable that exist in memory in a program at any given time.

  4. A function is a part of a program that performs a specific task, and is assigned a symbolic name.

  5. function prompt(“What’s your name?”)

  6. If any function or change or statement affects the program outside of that line, it is creating a side effect, changes that ripple further through the program.

  7. the prompt function has the side effect of opening a dialogue box to the user.
    console.log(Math.max(2,4)); produces a value without side effects.

  8. Control flow refers to the order in which the program will be executed. (Top to bottom, left to right.)

  9. A conditional execution is a part of a program, for example a certain task that can only be executed if certain external conditions are met.

  10. You could use the “if” keyword.

1 Like
  1. What is an expression?
    A “sentence” in a program.

  2. What is a binding?
    A variable.

  3. What is an environment?
    The program as a whole.

  4. What is a function?
    A subset of code that performs a specific duty. It may return a value or a “side effect”.

  5. Give an example of a function.
    console.log (“This is a function”)

  6. What is a side effect?
    Showing a dialog box or writing text to the screen.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    side effect -> prompt ("this is a side effect);
    value -> console.log (“This is a value”);

  8. What is control flow?
    Programs are executed top to bottom.

  9. What is conditional execution?
    Program can flow in multiple directions based on conditions.

  10. What kind of keyword do you need to use to invoke conditional execution?
    IF and ELSE

1 Like
  1. What is an expression?
    A fragment of code that produces a value.

  2. What is a binding?
    It catches and holds a value.

  3. What is an environment?
    The collection of bindings and their values that exist at a given time

  4. What is a function?
    A piece of program wrapped in a value.

  5. Give an example of a function.
    prompt
    Shows a dialog box and asks for a user input.

  6. What is a side effect?
    When a statement displays sth on the screen or it could change the internal state of the machine in a way that affects all statements coming after it.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert(“Hello”);
    2+2;

  8. What is control flow?
    The order in which statements are executed (from top to bottom).

  9. What is conditional execution?
    A branching road, where the program takes the proper branch based on the situation at hand.

  10. What kind of keyword do you need to use to invoke conditional execution?
    if

1 Like
  1. What is an expression?
    An expression is a piece of code that produces a value.

  2. What is a binding?
    A binding is used to catch and hodl values…d’ya see what I did there!!

  3. What is an environment?
    Whatever group of bindings and values which are currently operating, together are classified as the “environment”.

  4. What is a function?
    A function is a piece of programming encased in and assigned to a value.

  5. Give an example of a function.
    The “prompt” binding holds a function that calls up a dialog box with which the user can interact.

  6. What is a side effect?
    A statement which changes the “world” or “environment”

  7. Give an example of a function that produces a side effect and another function that produces a value.
    let one=1; console.log (one + one);

  8. What is control flow?
    The control flow is in essence the sequence in which the program is executed.

  9. What is conditional execution?
    A piece of program which checks to see if certain conditions are met before choosing which values to express.

  10. What kind of keyword do you need to use to invoke conditional execution?
    “prompt” “case” “class” “export” “let”

1 Like
  1. What is an expression?
    An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value. Conceptually, there are two types of expressions: those that assign a value to a variable, and those that simply have a value.

  2. What is a binding?
    Binding it happens by using Bind () method. by this method, we can bind an object to a common function, so that the function gives different result when its need.

  3. What is an environment?
    The collection of bindings and their values that exist at a given time is called
    the environment. When a program starts up, this environment is not empty. It
    always contains bindings that are part of the language standard, and most of the
    time, it also has bindings that provide ways to interact with the surrounding
    system. For example, in a browser, there are functions to interact with the
    currently loaded website and to read mouse and keyboard input.

  4. What is a function?
    A JavaScript function is a block of code designed to perform a particular task.

  5. Give an example of a function.
    function name ( parameter1, parameter2, parameter3 ) {
    // code to be executed
    }

  6. What is a side effect?
    A side effect is any application state change that is observable outside the called function other than its return value.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effects include: Modifying any external variable or object property (e.g., a global variable, or a variable in the parent function scope chain) … Calling any other functions with side effects

  8. What is control flow?
    When your program contains more than one statement, the statements are
    executed as if they are a story, from top to bottom. This example program
    has two statements. The first one asks the user for a number, and the second,
    which is executed after the first, shows the square of that number.

  9. What is conditional execution?
    Conditional execution is created with the if keyword in JavaScript. In the
    simple case, we want some code to be executed if, and only if, a certain condition
    holds. We might, for example, want to show the square of the input only if the
    input is actually a number.

  10. What kind of keyword do you need to use to invoke conditional execution? IF is the conditional execution.

1 Like
1.	What is an expression? 

A fragment of code that produces a value.

2.	What is a binding? 

To catch and hold values.

3.	What is an environment?

The collection of bindings and their values that exist at a given time

4.	What is a function? 

A piece of program wrapped in a value

5.	Give an example of a function. 

prompt()

6.	What is a side effect? 

Showing a dialogue box or writing a text to a screen

7.	Give an example of a function that produces a side effect and another function that produces a value.

prompt(“What is your name”);
console.log(Math.max(3,18,6) * 3);

8.	What is control flow?

When a program contains more than one statement and the statements are executed as if they are a story.

9.	What is conditional execution? 

when a program takes a branch/ action based on the situation at hand

10.	What kind of keyword do you need to use to invoke conditional execution?

if, else

1 Like

1. What is an expression?
An expression is a fragment of code that produces a value.

2. What is a binding?
A binding allows the computer to catch and hold values.
Example: let caught = 5*5;

  • Let is the the binding. Other examples of binding are: var and const.

3. What is an environment?
An environment is a collection of binding and their values that exist at a given time.

4. What is a function?
A function is a piece of program wrapped in a value.

5. Give an example of a function?
prompt(“enter passcode”);

  • Prompt holds a function that shows a little dialog box asking for user input.

6. What is a side effect?
A side effect is a function that modifies a state example changing the value of a variable or interacts with the outside world.

7. Give an example of a function that produces a side effect and another function that produces a value.

  • Function that produces a side effect: prompt(“Enter passcode”);
  • Function that produces a value: console.log(math.max(2,4));
    // 4

8. What is control flow?
The order function calls, instructions, & statements are executed or evaluated when a computer is running.

9. What is conditional execution?
During a control flow a conditional execution creates a branching road, where program takes a proper branch based on the situation.

10. What kind of keyword do you need to use to invoke conditional execution?
Key word “if” in Javascript.

1 Like
  1. An expression is a line of code that conveys some logical statement.

  2. A binding keyword assings a value to a variable

  3. an environment is a place where bindings and values coexist.

4 a function is a set computation that takes various inputs (0-n) and returns some set of outputs

  1. function add(let a, let b) {return (a+b);}

  2. a side effect is a change to the environment

  3. prompt(“Hello World”); function add (let a, let b) {return a+b;}

  4. the sequence and rules governing the order of execution

  5. if, else

1 Like

1. What is an expression?
A fragment of code that produces a value.

2. What is binding?
A mapping of a variable to its memory location.

3. What is an Environment?
The collection of binding and their values that exist at a given time.

4. What is a function?
A piece of a program that performs a specific task. A function can take 0 or more arguments and can return 0 or more values.

5. Give an example of a function.
Example of a system-defined function: Math.abs()

6. What is a side effect?
Side effects define how a function changes the outside world.

7. Give an example of a function that produces a side effect and another function that produces a value.
Example of a function that produces a side effect:
var a = 0;
const test = (b,c) => {
a = b+c;
return a ;
};
test(2,3);
Here the test() is modifying the value of “a” which belongs to the outside world.

const test = (b,c) => {
var a = 0;
a = b+c;
return a;
};
test(2,3);
Here test() is a function without side effect as it is not modifying any variable which is outside the scope of a function.

8. What is a control flow?
Control flow defines the execution of program statements.

9. What is conditional execution?
Execution which depends upon the evaluation of a boolean expression.

10. What kind of keyword do you need to use to invoke conditional execution?
if, if-else, switch

1 Like
  1. An expression is anything that produces a value
  2. A binding is a second typ of statement, a variable that gives the computer a command.
  3. An environment is a collection of bindings and their values.
  4. A function is a variable that directs the computer to take a specific action
  5. function countApples (janesApples, bobsApples) {
    return janesApples + bobsApples;
    }
  6. A side effect is an action produced by a cuntion, for example, a dialog box
  7. A function that produces a side effect:
    var textToShow = “Hello World!”;
    alert(textToShow);

Function that produces a value

var a = 5
var b = 6
console.log(a+b)

  1. The control flow is the order that functions, statements, and other commands are executed
  2. Conditional Execution is code that executes “if” or “else” functions.
  3. They keywords "if or “else”
1 Like
  1. What is an expression?
    A fragment of code that produces a value is called an expression.

  2. What is a binding?
    bindings grasp values basically reference or point to a variable or a value

  3. What is an environment?
    The collection of bindings and their values that exist at a given time is called
    the environment

  4. What is a function?
    A function is a piece of program wrapped in a value. group of code that can be called by a program to compute a value

  5. Give an example of a function.
    isNan() is a global function example used to evaluate if a falue is an illegal number
    web3.eth.getAccounts(function(e,accounts);

  6. What is a side effect?
    a function which produces an expression and returns that value

  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert(“alert is a function that produces a side effect”)
    console.log(1+1); produces a value

  8. What is control flow?
    the order of executing code from top to bottom left to right

  9. What is conditional execution?
    when using a logical operator to determine wether or not to execute certain perts of the code

  10. What kind of keyword do you need to use to invoke conditional execution?
    'if" is the keyword to invoke conditional execution

1 Like

1 A fragment of code that produces a value.
2 A variable that can catch and hold values.
3 The whole of bindings and their values that exist at a given time.
4 It is a piece of program contained in a value.
5 console.log(“Hello, World!”);
6 A function which produces an expression and returns that value.
7 alert(“Hello, World!”);
8 It’s a top to bottom program execution.
9 A command which execute in base of a condition.
10 if, else.

1 Like
  1. A expression is a fragment of code that produces a value. Every value that is written literally is also expression.

  2. Java Script uses bindings to catch and hold values, if not immediately use it will be disappear

  3. The collection of bindings and their values that exist at a given time is called a environment.

  4. A Function is a piece of program wrapped in a value.

  5. The binding Prompt holds a function that shows a little dialogue box asking for user input.

  6. Side effects are when a statement stands on its own, so it amounts to something only if it affects the world. It could display something on the screen-that counts ass changing the world-or it could change the state of the machine in a way that will affect the statements that come after it.

  7. The prompt function produces a dialogue box which could be a side effect. The function Math.max will give you the amount of number arguments and gives back the greatest.

8.When your program contains more than one statement or the statements are executed as if they are a story, from top to bottom.

  1. Condition Execution is when you need to create a branching road, where the program takes the proper branch based on the situation at hand.

  2. The keyword if.

1 Like

1. What is an expression?

An expression is a fragment of code that produces a value, such as 22 or “psychoanalysis”.

2. What is a binding?

A binding is something that points to a value. In the example let caught = 5 * 5;:

  • let is the keyword that tells Javascript that the sentence will define a binding.
  • caught is the name of the binding, followed by the = operator. Some binding names cannot be used, such as break, case, enum, etc.
  • the value given by 5 * 5 is the value the binding points to, and this value can be changed

So, a binding is similar to a variable in that it stores values which can be changed later on.

3. What is an environment?

An environment is the collection of bindings and their values that exist at a specific time. Even if no bindings have been defined by the programmer yet, when the program starts, the environment is not empty as it contains bindings for “behind-the-scenes” stuff.

4. What is a function?

A function is a piece of program stored in a value. You can call the function by typing the function name followed by parentheses, such as…

5. Give an example of a function.

…such as prompt(). The values given to functions are placed inside the parentheses and they are called arguments. Here, prompt(“Enter passcode”) is a function that causes a dialogue box saying, “Enter passcode” to appear in the browser.

6. What is a side effect?

A side effect is the result of calling a function. For example, the side effect of prompt() is that it shows a dialog box.

Some functions may not have any side effects, but instead return values. For example, a function that takes the maximum of two numbers does not show a dialog box or write text to the screen. Instead, it returns a value: the maximum of the two numbers.

7. Give an example of a function that produces a side effect and another function that produces a value.

Side effect - prompt(“Is it dialog or dialogue?”)
// --> Shows a dialog box saying, “Is it dialog or dialogue?”
Return value - Math.max(6, 19);
// --> 19

8. What is control flow?

Control flow is the direction that code will be executed. Code is always run from top to bottom.

9. What is conditional execution?

Conditional execution is when the program is given two or more possible “paths” to follow, and based on some condition it will follow one path.

10. What kind of keyword do you need to use to invoke conditional execution?

  • if - used to specify the block of code to execute if a condition is true
  • else - used to specify the block of code to execute if the same condition (from the if statement) is false
  • else if - creates another conditional path to choose from and specifies the block of code to be executed afterwards
1 Like
  1. What is an expression?
    It is a part of a code that produces a value
  2. What is a binding?
    A binding allows catching or holding on an expression with a specific value to be used subsequently
  3. What is an environment?
    Collection of bindings and their values that exist at a given time
  4. What is a function?
    Piece of program wrapped in a value
  5. Give an example of a function.
    console.log(crypto2);
  6. What is a side effect?
    Side effects are produced by functions, it could be a dialog box or text written on the screen
  7. Give an example of a function that produces a side effect and another function that produces a value.
    prompt(“Enter your username and password”);
    console .log(hello, world);
  8. What is control flow?
    It is a linear execution of statements
  9. What is conditional execution?
    When the program executes statements based on conditions applied
  10. What kind of keyword do you need to use to invoke conditional execution?
    “if“, “else if” and “else”
1 Like

What is an expression?

A fragment of code that produces a value. Expressions can contain other expressions in a way similar to how subsentences in human languages are nested. This allows us to build expressions that describe arbitrarily complex computations.

What is a binding?

The keyword let indicates that a sentence is going to define a binding. It is followed by the name of the binding and, if we want to immediately give it a value, by an = operator and an expression. When a binding points to a value, that does not mean it is tied to that value forever. The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one.

What is an environment?

The collection of bindings and their values that exist at a given time.

What is a function?

A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program. For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input. Values given to functions are called arguments. Different functions might need a different number or different types of arguments.

Give an example of a function.

console.log

What is a side effect?

Showing a dialog box or writing text to the screen is a side effect.

Give an example of a function that produces a side effect and another function that produces a value.

prompt(“Enter passcode”);

console.log(Math.max(2, 4) + 100);

What is control flow?

When your program contains more than one statement, the statements are

executed as if they are a story, from top to bottom.

What is conditional execution?

Conditional execution is created with the if keyword in JavaScript. In the

simple case, we want some code to be executed if, and only if, a certain condition

holds.

What kind of keyword do you need to use to invoke conditional execution?

The if keyword executes or skips a statement depending on the value of a Boolean expression.

1 Like
  1. What is an expression?
    Fragment of code that produces a value. In human sentence, expression would be sentence fragment.
  2. What is a binding?
    Binding is basically variable, it allows program to remember assigned value to variable so you can call them again.
  3. What is an environment?
    Bindings and their values are called environment.
  4. What is a function?
    a piece of program wrapped in value.
  5. Give an example of a function.
    console.log(“hello world”)
  6. What is a side effect?
    any state change that is outside the called function other than its return value.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    settimeout(), console.log(2+4)
  8. What is control flow?
    When program contains more than one statement.
  9. What is conditional execution?
    When the program takes the proper branch based on the situation at hand.
  10. What kind of keyword do you need to use to invoke conditional execution?
    if
1 Like
  1. An expression is a fragment of code that produces value.
  2. The function in Javascript enabling us to hold values.
  3. It refers to the collection of bindings and their values that exist at a given time.
  4. A function is a piece of a program wrapped in a value.
  5. Console.log function
  6. A side effect is the result obtained from a function.
  7. Conditional execution functions produce side effects while control flows produce values.
  8. A control flow is a straightforward function.
  9. a branching function.
  10. The if keyword.
1 Like