Binding, Functions and Control Flow - Reading Assignment

  1. An expression is:
  • a fragment of code that produces a value,
  • every value that is written literally (12 or “mother”),
  • an expression between parentheses,
  • a binary operator applied to two expressions,
  • a unary operator applied to one expression.
    Expressions can contain other expressions.
  1. A binding or variable is used in JS when a new produced value has to be used, so that the original value remains intact. So we catch and hold values. A special word - keyword(let, var, const) indicates that the sentence is going to define a binding, this is followed by the name of a binding. In order to produce a value these two are followed by an operator and an expression. After a binding has been defined, its name can be used as an expression.
    e.g.
    let salary = 12 * 800;
    let years = 10;
    console.log(salaryyears);
    96000
    to produce the value of the salary earned in 10 years
    And this can be changed. A binding points at a value, an operator can be used on existing bindings to disconnect them from their current value and have them point at a new one.
    years=12
    console.log(salary
    years);
    115200
    To display the salary earned in 12 years.

  2. An environment is a collection of bindings and their values that exist at a given time.
    A program always contains bindings that provide ways to interact. e.g. in a browser there are functions that interact with the currently loaded website and to read mouse and keyboard input. When we want to access this page from the page of the academy, we do it through the link that has a function written behind that leads us here where we choose to Reply clicking with the mouse and writing in this box.

  3. A function is a piece of program wrapped in a value. Executing a function is called invoking. Arguments are values given to functions.

  4. Examples:

  • prompt(“Enter passcode”); - not often used,
  • console.log(); to output values - often used.
  1. A side effect is:
  • showing a dialog box (alert, prompt function) or
  • writing text to the screen.
  1. e.g. function that produces a side effect: alert(“Hello world!”);
    e.g. function that produces a value: console.log(2+4);

  2. Control flow means that the statements in a program are executed from top to the bottom.

  3. Conditional execution in JS means we want some code to be exectuted if, and only if, a certain condition holds.

  4. if, (together with else to create two alternative execution paths)

1 Like
  1. A fragment of a 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. function myFunction (p1,p2){
    return p1*p2;
    }
  6. Any application state change that is observable outside the called function other than its return value
  7. Function that produces a side effect = alert(" ")
    Function that produces a value = console.log(Math.max(2, 4));
  8. An order in which statements are executed as if they are a story, from top to bottom
  9. A statement that executes actions based on different conditions
  10. if
1 Like
  1. What is an expression?
    An expression is a fragment of JavaScript code that produces a value.

  2. What is a binding?
    Binding refers to the mechanism where a label is linked to a value so that the value can be reused in codes by citing the label.

  3. What is an environment?
    An environment is the collection of existing bindings and their values at a given time.

  4. What is a function?
    A function is a piece of program that can be invoked by another program by calling the binding linked to the function.

  5. Give an example of a function.
    An example of a function is the prompt function which shows a dialogue box in a web browser and accepts user inputs .

  6. What is a side effect?
    A side effect is the impact of executing a JavaScript statement. It can either be an action performed outside of the computer system (for example, sending information to an output device such as the monitor) or a change in the internal state of the system, such as altering the value of a variable stored in the memory.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    The function prompt produces the side effect of displaying a dialogue box and accepts inputs. The function Math.max produces a value that equals to the largest value in the arguments.

  8. What is control flow?
    Control flow is the order by which statements in a program are executed.

  9. What is conditional execution?
    Conditional execution is a break from linear control flow depending on how the situation at hand compared to prespecified conditions.

  10. What kind of keyword do you need to use to invoke conditional execution?
    The keywords if, else, and else if are used to invoke conditional execution.

1 Like
  1. An expression is any valid unit of code that resolves to a value
  2. A connection between two value’s
  3. The collection of bindings and their values that exist at a given time is called
    the environment
  4. A function is a piece of program wrapped in a value.
  5. prompt(“enter password”);
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. "hello world" console.log(2*4)+7
  8. the flow of execution of all the statements from top to bottom
  9. the flow of the execution is based on conditional values
  10. if
1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is a variable defined by the keyword let.
  3. An environment is 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. The prompt function asks for user input through a dialog box in a browser environement.
  6. A side effect is something that changes the internal state of the machine.
  7. console.log produces a side effect and Math.max returns a value.
  8. Control Flow is the execution of a number of statements of a program from top to bottom.
  9. conditional execution is branching the flow of a program depending on certain conditions.
  10. conditional execution is invoked with the keyword if.
1 Like
  1. What is an expression?
    A fragment of code that produces a value is called an expression

  2. What is a binding?
    To catch and hold values, JavaScript provides a thing called a binding, or variable.
    The special word (keyword) let indicates that this sentence is going to define a binding
    (The words var and const can also be used to create bindings, in a way similar
    to let.)

  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

  5. Give an example of a function.
    Prompt has a function inside it that returns the users input from a input box on screen

  6. What is a side effect?
    If a function changes something outside of the function’s context

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

  • console.log
  • math.min
  1. What is control flow?
    The flow of execution. (straight, conditional, etc)

  2. What is conditional execution?
    Some code will be executed if, and only if, a certain condition holds.

  3. What kind of keyword do you need to use to invoke conditional execution?
    If
    else if
    else

1 Like

What is an expression?

Any piece of code that either is a value or resolves to a value.
The resulting value may be a number, string or logical value.

Statement: full sentence made of code fragments or expressions.

Program: List of statements

What is a binding?

A binding is a way for a program to preserve a state. A binding is used to grab/catch/hold a value, which can be changed. A binding is therefor a named variable.

What is an environment?

Program state that contains default bindings and their values.

What is a function?

Piece of code wrapped in a value (). A function can be called/executed/invoked/applied

Give an example of a function.

Expression (value)

Keywords: if, else, let, do etc.

What is a side effect?

The result of the execution of a statement (full sentence) that does not just return a value but affects the “world”

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

alert (“Hello”)

let one = 1, two = 2

console.log (one+two)

// 4

What is control flow?

If a program has multiple statements they are exectued in order of Left to Right, Top to bottom. This is the control flow.

What is conditional execution?

A program can introduce conditions which direct the control flow.

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

If (condition is true), else (condition is false), else if (test new condition if first one is false)

1 Like
  1. A fragment of code that produces a value
  2. To catch and hold values, JavaScript provides a thing called a binding
  3. The 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(“Crypto will save the world”)
  6. Showing a dialog box or writing text to the screen is a side effect
  7. prompt(“enter password”) will give you side affect a dialog opens where you can enter your password.
    console.log(Math.max (2, 4)); will give back the biggest value. In this case 4
  8. Controlflow is the order in witch we execute the code and have our statements evaluated.
  9. If you want to create a branching road, where the program takes the proper branch based on the
    situation at hand.
  10. If, else
1 Like

1.- A piece of code that produces a result
2.- a place to store values
3.- Collections of bindings and their values at a given time
4.- Is a piece of program you can reuse and performs an operation
5.- Math.max(valueA, valueB)
6.- It’s something that happens after invoking a function
7.- Alert(“Hello”);
f(x)= x +1; f(1)=2;
8.- Is the order in which the computer executes statements in a script
9.- The execution of the statement only occurs if the condition was satisfied
10.- IF, ELSE

1 Like
  1. A fragment code that produces a value.
  2. To catch and hold values.
  3. The collection of bindings and their values that exist at a given time.
  4. A piece of program that is wrapped in a value.
  5. prompt function which hold a function that shows dialog box asking for user input -> prompt(“Enter passcode”);
  6. Is a changes in the internal state of the machine in a way that will affect the statement that come after it.
  7. Function that produces side effect = alert(“hey”);
    Function that produces value = console.log(Math.max(12314, 21311));
  8. When your program contains one statement, the statements are executed as if they are a story, from top to bottom.
  9. This is where in the code will only be executed if, only if, a certain condition is fulfilled.
  10. if, else, else if, switch.
1 Like
  1. An expression is any fragment of code that produces a value.
  2. A binding (or variable) is a reference (not a container) to a value/expression.
  3. An environment is the set of variable and values they reference that are available/exist in a program at a given time
  4. A function is a piece of code that wraps a value.
  5. console.log() is a function
  6. Side effects are the effects yielded by changing an expression inside the program which “reverberate” on the rest of the program itself, therefore potentially changing the results produced.
  7. !false --> side effect example
    console.log(Math.min(0, 2)) --> the output a value that is 0

8.Control flow is the direction the code is read and executed: top to bottom and left to right.
9. It’s code that can branch in order to allow different results when different inputs are inserted.
10. The keywords used are if/else if/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?
A binding(variable) is a named piece of computer memory to grab and hold 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 block of code designed to perform a particular task.
5. Give an example of a function.
function my Function(x1, x2) {
return x1 * x2; }
6. What is a side effect?
Showing a dialog box or writing text to the screen is aside effect.
7. Give an example of a function that produces a side effect and another function that produces a value.
side effect example:
prompt(“Pick a number”);
produce a value:
console.log(Math.min(3, 5));
// 3
8. What is control flow?
When the program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
9. What is conditional execution?
Conditional execution controls whether or not the program will execute an instruction. 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. It’s a fragment of code that produces a value.
  2. A binding (or variable) is the way a program can hold (remember) a value. It is not tied to the value, it can disconnect from its current value and grab a new one.
  3. It is the collection of bindings and their values at a given time.
  4. A piece of program wrapped in a value.
  5. prompt(" “);
    alert(” ");
  6. A side effect is a dialog box or text that appears in the screen.
  7. The examples in 5 are side effects.
    Function that produces a value:
    console.log(Math.min (7, 10));

    7

  8. Is the order in which the statements of a program are executed (top to bottom).
  9. When a program has some conditions it creates alternative execution paths.
  10. Keywords: If, else.
1 Like
  1. What is an expression?
    A fragment of code that produces a value
  2. What is a binding?
    A way to catch and hold values
  3. What is an environment?
    A collection of bindings and their values at any given moment
  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?
    A visible change on screen e.g. showing a dialog box
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect function:
    prompt(“Enter password”);
    Value function:
    console.log(1 + 2)
  8. What is control flow?
    The order in which the computer executes statements in a script
  9. What is conditional execution?
    It is whether a program will continue or not based on certain condition being met
  10. 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 creates a value. Expressions can be within expressions like a sub-sentence in the English language.
  2. A program uses a binding to grasp a value when it needs to remember it. Examples of bindings are Let, Var, and Const. A single Let statement can define multiple bindings but each must be separated by a comma.
  3. The collection of bindings and there values at any one time is a programs environment. When a computer starts up, it initiates a program containing bindings around language protocols and function that interact with the hardware and interface of the machine.
  4. A function allows you to define a block of code, name it and repeat it as a task. For example this happens in the default environment when you turn on the computer. Allot of values in this environment use the Type of function.
  5. function go() {alert (‘hi’);
    alert (‘hey there’);}
    go();
  6. A side effect is a statement that alters the world through either the output in an interface or the internal drive of the machine.
  7. Function that produces a side effect :
    function go() {alert (‘hi’);
    alert (‘hey there’);}
    go();
    Function that produces a value :
    console.log(Math.max(2, 4));
    // → 4.
  8. When a program contains more than one statement it is put in order like a story from top to bottom. This is called control flow.
  9. Control flow can branch in different directions if certain conditions are met .
    10.This can be achieved by using parameters set out by the keyword " if ".
1 Like
1. What is an expression?
    1. A program compiled of expressions that have side effects.
2. What is a binding?
    1. A connection that allows programs to store and access values.
3. What is an environment?
    1. Collection of bindings & their corresponding values
4. What is a function?
    1. A piece of program that can be invoked by calling/applying the argument (value it’s wrapped in).
5. Give an example of a function.
    1. prompt(“Do not enter passcode”);
6. What is a side effect?
    1. The resulting change/action from a statement.
7. Give an example of a function that produces a side effect and another function that produces a value.
    1. Side Effect:
        1. prompt(“This is a Side Effect”);
    2. Value: 
        1. console.log(Math.max(2, 4));
8. What is control flow?
    1. A program’s order of operations for executing statements
9. What is conditional execution?
    1. Control flow with a branching order of operations that diverge based on the conditions at point of execution.
10. What kind of keyword do you need to use to invoke conditional execution?
    1. “if” / “else”
1 Like
  1. A fragment of code that produces a value
  2. Binding is a variable that stores information that can be used later.
  3. The collection of bindings and their values that exist at a given time
  4. A piece of program wrapped in a value
  5. prompt(“Enter today’s date”)
  6. Showing a dialog box or writing text to the screen
  7. Side effect - prompt(“Enter last name”)
    Value example - console.log(Robinson)
  8. The order in which code is read
  9. Rerouting how the code to executes lines only on certain conditions
  10. Keyword if, else
1 Like
  1. What is an expression?

An expression in JavaScript is a program, which is code that produces a value.

  1. What is a binding?

Binding is a connection between an object to a function,. These connections can be re-connected so that the functions gives different results. It’s a way for a program to keep an internal state in memory.

  1. What is an environment?

An environment is a state in which initial programs help control or interact with a GUI, keyboard, mouse, etc… A collection of bindings and their values already exist in it’s initial condition.

  1. What is a function?

A regular binding where the value of the binding is a function. Functions are invoked when putting parentheses after an expression, where that expression produces a function value. Values to functions are called arguments.

  1. Give an example of a function

function toCelsius(kelvin) {

return (0 - 273.15) + (kelvin);

}

toCelcius(305);

// 31.850000000000023

  1. Showing text on a screen or displaying a dialog box are side effects of functions.

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

function producing a side effect:

promt(“Click Here”);

function producing a value:

console.log(Math.min(3, 6) + 10);

// 13

  1. What is control flow?

A program that contains more than one statement from top to bottom.

  1. What is a conditional execution?

A program that can inspect the arguments so that it can verify the input and thus give an answer if conditions are met.

  1. Since it’s a conditional statement, the keyword used is:

if

1 Like
  1. string of values and operators that produce a value;
  2. binding is a label assigned to a value or points to a value
    3, an environment is the collection of bindings and values at a given point in time.
  3. a function is collection is statements or program wrapped in a value.
  4. example of a function is console.log() prompt() …
  5. function executes and produces only a single value when it returns has no side effect. if it displays a value some where or change the state of some variable then it has a side effect. the side effect is any bit of state that changes not relating to the return value.
  6. prompt has a side effect, max() does not.
  7. the order of a programs execution flow. normally this is from top to bottom.
  8. when a program needs to execute alternative path given some condition holds.
  9. if
1 Like

Hello everyone,

  1. A code that produces a value is called an expression.

  2. A binding (or variable) catches and holds value

  3. A collection of variables (binding) with its values that are created at a given time is called environment.

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

  5. Boolean()

function add(a,b) {
    return a + b;
}
  1. Writing text to a screen or showing a dialogue box is called side-effect.

  2. Eg of a function which produces a side-effect.

console.log(Math.min(5,10));

Eg of a function which produces a value.

console.log(Math.min(5,10) -2);
  1. When the program contains a bunch of statements, the statements get executed in order from top to bottom. This is called the control flow.

  2. When a function has two or more possibilities it’s executed by if else statements. This is a conditional execution.

  3. if
    else if
    else

1 Like