Binding, Functions and Control Flow - Reading Assignment

  1. An expression is a piece(fragment) of code that produces a value.
  2. Binding(of a variable) is a way the computer keeps its memory assigned as a tentacle(loose box) to the variable, which can later be used as an expression.
  3. An environment is a set of variables and their values that exist in memory at a given time.
  4. A function is a wrapped piece of Program with values, that performs/returns a specific task.
  5. an Example of a function is as Follows:
    function cube(number) {
    return number * number * number
    }
    console.log(cube(3));

another example:
let num = Number(prompt(“Enter a number of your choice”));
if (num <10) {
console.log(“The number is small”);
}
else if (num 10 < 100){
console.log(“The number is Medium”);
}
else {
console.log(“The number is Big”);
}

  1. The above two are examples of functions with side effects.
    When functions return values using Invoked arguments(values) to allow the computer to compute(calculate) and arrive at values even outside the scope the function itself, then this is called a “Side effect”

prompt(“Are you liking this Course?”);
this is producing no value outside the function.

function cube(number) {
return number * number * number
}
console.log(cube(3));
this is a function which is creating a value outside the scope of the Function.

  1. Control Flow is the direction of execution of a code in JavaScript and it happens in a Top down approach.

  2. Conditional Execution is a Branch of control Flow’s execution, where JS executes this Branch if some Parameters are present.
    example
    if (typeof web3 !== “undefined”)
    else {alert(“Could not find Web 3.0 provider, Please visit metamask.io or download the Ethereum Mist Browser”);
    }

  3. If, Else if, Else, Switch

1 Like
  1. What is an expression?

A fragment of code that produces a value is called an expression. Every
value that is written literally (such as 22 or “psychoanalysis”) is an expression.

  1. What is a binding?

Binding is a way a program keeps an internal state. Binding stores value so that we can use it later. Binding is a variable.
let caught = 5 * 5;
By using the keyword let before defining a variable lets JavaScript know the sentence is going to define a variable, and it is naming this binding with name > caught.

  1. What is an environment?

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

  1. 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.

  1. Give an example of a function.

For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input. It is used like this:

prompt(“Enter passcode”);

  1. What is a side effect?

An expression can be content to just produce a value, which can then be used by the enclosing code. 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 as changing the world—or it could change the internal state of the machine in a way that will affect the statements that come after it. These changes are called side
effects.
Showing a dialog box or writing text to the screen is a side effect. A lot of
functions are useful because of the side effects they produce. Functions may
also produce values, in which case they don’t need to have a side effect to
be useful.

  1. 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));

  1. What is control flow?

It is the direction of execution of code in JavaScript which happens in a top down approach, the statements are executed as if they are a story, from top to bottom.

  1. What is conditional execution?

Not all programs take straight-line control flow. We may, want to create a branching road, where the program takes the proper branch based on the situation at hand or condition that we give it. This is called conditional execution. Conditional execution is achieved with the if and else keywords.

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

if
to specify a block of code to be executed, if a specified condition is true

  • Use

else
to specify a block of code to be executed, if the same condition is false

  • Use

else if
to specify a new condition to test, if the first condition is false

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

  2. What is a binding?
    Binding or variable is when a value is assigned to a Name of the binding.

  3. What is an environment?
    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.
    const square = function(x) {
    return x * x;
    };

  6. What is a side effect?
    When an operation can change the world, or some internal state of the computer.

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

const square = function(x) {
return x * x;
};
x = prompt("write a number ");
console.log(square(x));

  1. What is control flow?
    It is the algorithm or logical sequence of sequenced steps that the computer follows one by one.

  2. What is conditional execution?
    It is the logical operator that determines what sequences of code to execute in base of defined condition.

  3. What kind of keyword do you need to use to invoke conditional execution?
    if, if-else, while, for.

1 Like
  1. What is an expression? A fragment of code that produces a value
  2. What is a binding? Also known as variable, binding is a process of holding a value
  3. What is an environment? An environment is a collection of bindings 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. Math.min(x,y,z…)
  6. What is a side effect? When a function produces effect like showing a dialog box or writing text to the screen as part of the call
  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 (“string”); function that produces the value: Math.min (4,10, 34)
  8. What is control flow? Control flow is the execution of the program from one statement to another from top to bottom
  9. What is conditional execution? It is when a 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 key word and use in the following context if (value or expression) {statement to be executed if condition is true}
1 Like
  1. An expression is a piece of code that produces a value. Every value that is written directly is an expression. A binary operator applied to two expressions, and a unary operator applied to one, is also an expression.

  2. A binding is a variable, this allows us to assign a value to the variable and recall it from the computers memory at a later time.

  3. An environment is a collection of variables and their values that exist at a given time. When a program is fired up the environment is not empty. It contains a number of standard variables in it. When your browser loads a page, it creates a new environment and attaches these standard values to it. The variables created and modified by programs will survive until a new page is loaded.

  4. A function is a piece of program wrapped in a value. Generally, this piece of program does something useful, which can be evoked using the function value that contains it.

  5. The variable alert is a good example of this, it holds a function that shows a dialog box with a message in it.

  6. A side effect is a byproduct of a function. A lot of functions are considered useful because of the side effects they produce.

  7. Side effect example: prompt(“Do you like oranges?”)
    Value example: console.log(Number2 * Number8)

  8. When a program has more than one statement, the statements will be executed as if they are a story. This is considered control flow.

  9. Conditional execution applies a set of conditions to the control flow. This allows the program to be executed within the conditions the programmer sets forth. So we can lead end user down different paths depending on their answers to certain conditions implemented in the program.

  10. If and else

1 Like

Reading Assignment Answers:

1.Fragment of code that produce value.
2.Used to catch and hold value together.
3.A collections of bindings and their values existing at a given time.
4.A piece of a program wrapped in value.
5.Console.log
6.An execution of a program/statement.
7.Prompt/Alert/console.log
8.When program contains more that one statement.
9.When program takes proper branch to execute.
10. If

1 Like
  1. Expression is a fragment of code that produces a value.
  2. Binding catches and hold values like tentacles. Only grasps values.
  3. Environment is the collection of bindings and their values that exist at a given time.
  4. Function is a piece of program wrapped in a value. Function is a block of code
    designed to perform a particular task.
  5. prompt (“Type in Ivy”);
  6. Side effect is anything that compromises the purity of a function. Showing a dialog box or writing text to the screen is a side effect.
  7. Function produces side effect: prompt (“Type in Ivy”);
    Function produces value: function myFunction (a, b) {return a*b; }
  8. Control flow: Statements are executed from top to bottom.
  9. Conditional Execution is used to decide the flow of execution based on different condition.
  10. keywords: IF, ELSE, ELSE IF
1 Like
  1. What is an expression?
    Answer: A fragment of code that produces a value

  2. What is a binding?
    Answer: A variable that is bound to an expression by an operator.

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

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

  5. Give an example of a function.
    Answer: (5 * 5)

  6. What is a side effect?
    Answer: A statement that changes something about the internal state of the machine in a way that affects the statements that come after it.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Answer: Function producing side effect: prompt(“Enter passcode”);
    Function producing a value: var x = 5 * 5;

  8. What is control flow?
    Answer: When your 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?
    Answer: 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?
    Answer: The “if” keyword.

1 Like

1.- A fragment of code that produces a value. An expression between parentheses is also an expression.
2.- Biding or variable is where the values are cached and hold.
3.- The collection of bindings and their values that exist at a given time.
4.-It´s a price of program wrapped in a value, then such values can be applied in order to run the wrapped program.
5.- Prompt(“Enter passcode”);
6.- Side effect is a change of system state or observable interaction with the outside world that occurs during the calculation of a result.
7.- Generate output beyond the return value:
Const compute = (x, y) => {
Const z = x + y;
Console.log(z);
Return z;
}

8.- It´s a program that contains more than one statement.
9.- It´s created with the “if” keyword. We want some code to be executed if, and only if, a certain condition holds.
10.- If

1 Like
  1. Expression consists of value(s) and operation(s) and could be a long string of values and operations. They are a fragment of a code that produces a value.

  2. A binding is a function that binds and holds a value.

  3. A collection of values and operations that exist at any given time.

  4. Function is a pice of program wrapped in a value.

  5. (var, console.log, prompt, sum, if) etc.

  6. Side effect is an unexpected consequence of a statement, such that it changes the statements that come after it.

  7. (If, else), functions that have side effects. (var, alert), functions that produce a value(s).

  8. Control flow is setting up a function in such a way that it has multiple value outputs with respect to what value the user inputs.

  9. Conditional execution is the execution of a set of variables if a input is in line with a set of conditions.

  10. (else).

1 Like
  1. A fragment of code that produces a value. Every value that is written literally. It is a statement with a semi colon after it.
  2. Attaching a value to a variable / assigning a value to a variable.
  3. Is the collection of variables and their values that exist at a given time.
  4. Is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.
  5. alert(“Good Morning”)
  6. It is the way an expression affects/changes the statements that comes after it. Showing a dialog box or writing text to the screen.
  7. console.log(“Good Morning”) = side effect function.
    console.log(Math.max(2,4)) = function that produces a value.
  8. The order in which a program/piece of code is executed.
  9. Is the execution of a program by choosing from a series of options based on a boolean value.
  10. if, else if, else.
2 Likes

What is an expression?

a fragment of code that produces a value

What is a binding?

another term for variable that means to catch and hold values

What is an environment?

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

What is a function?

a piece of program wrapped in a value

Give an example of a function.

“prompt” holds a function that shows a dialog box to the user

What is a side effect?

showing a dialog box or writing set to the screen

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

“prompt” would be a function producing a side effect, “Math.max” is a function that produces a value

What is control flow?

a program containing more than one statement that is read from top to bottom.

What is conditional execution?

the program will take the proper branch based on the situation at hand .

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

“if” and “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 is a way for you to attach a variable to a key word internally so you dont have to right the variable out every time you want instead you can just rewrite the key word
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(“Enter passcode”);
6. What is a side effect?
something that changes the world or it could change
the internal state of the machine in a way that will affect the statements that
come after it thats a side affect
7. Give an example of a function that produces a side effect and another function that produces a value.
console.log(“hello there”)
Math.min(2, 4);
8. What is control flow?
the order in which everything is executed which is top to bottom
9. What is conditional execution?
a conditional execution is when u have certain conditions that have to be met for expression to expression to execute
10. What kind of keyword do you need to use to invoke conditional execution?
if

1 Like
  1. What is an expression?
  • A fragment of code that produces a value
  1. What is a binding?
  • A binding is how a program remembers / stores in memory a value referenced that can be recalled and used later.
  1. What is an environment?
  • The environment in Java Script is the collection of bindings and their values that exist.
  1. What is a function?
  • A function is a piece of program wrapped in a value and be executed by calling its value applied.
  1. Give an example of a function.
  • alert(“hello”);
  1. What is a side effect?
  • Side effect is an observable change directly caused by the program in the world. For example, causing the browser to show a pop up box and ask for input.
  1. 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(2+4); produces a value
  1. What is control flow?
  • When a program is executed it reads top to bottom, if a program has multiple statements it will execute is line in this way.
  1. What is conditional execution?
  • Conditional Execution is is where the program decides what to do providing defined conditions within the expression.
  1. What kind of keyword do you need to use to invoke conditional execution?
  • ‘if’ is the keyword to invoke conditional execution.
1 Like
  1. What is an expression?
    A Fragment of Code that produces a value
    Every Value that is written literally is an expression

  2. What is a binding?
    A binding catches and holds values.
    The binding value can be disconnected an be changed to a new value. 2 bindings -> 1 value

  3. What is an environment?
    An enviroment is a collection of bindings and their values

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

  5. Give an example of a function.

function myFunc(theObject) {
theObject.brand = “Mercedes”; }

var mycar = {
brand: “Mercedes”,
model: “190d”,
year: 1987
tax status: “Oldtimer”};

console.log(mycar.brand);

myFunc(mycar);

console.log(mycar.brand);

  1. What is a side effect?
    A sideeffect is a function that produces an expression and returns the given value.

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

let num = 0;
const func = () => {
num = 1;
return true;
}
func();

  1. What is control flow?
    Control flow describes the execution order statements. They get executed one after another, top to bottom.

  2. What is conditional execution?
    A conditional execution is a branch in the code. The branch which will be selected depends on the situation on Hand.

  3. What kind of keyword do you need to use to invoke conditional execution?
    -> if
    Example:
    if ( condition ) {
    // block of code to be executed if the condition is true }
    else {
    // block of code to be executed if the condition is false }

What is an expression?

A fragment of code that produces a value is called an expression, Every value that is written literally (such as 22 or “psychoanalysis”) is an expression

What is a binding?

its a value that we give to a variable, it is remember by the system, it begin with keywords like var, const or let.

What is an environment?

a collection of bindings and their values

What is a function?

Its a piece of program wrapped in a value, such value can be applied to run a program ex: prompt, math.max , math.min , Number

Give an example of a function.

math.max give you the highest of a serie of numbers

What is a side effect?

Showing a dialog box or writing text to the screen is a side effect . A lot of functions are useful because of the side effects they produce

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

side effect = console.log(“hello world”); or prompt(How many cheese do you want?)

value = let five = (10 – 5)

What is control flow?

it is the order of your program it can be in a straight line or it can have condition like if and else

What is conditional execution?

an action will only occur if a condition is met in the program

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

if , else , !

  1. It is a fragment of code that produces value. Every value that is written literally is an expresion.
  2. Bindings don’t contain values, they grasp them - two bindings can refer to the same value.
  3. The collection of bindings and their values that exist at a given time.
  4. It is a piece of program wrapped in a value.
  5. alert(“Hello, World!”);
  6. Showing a dialog box or writing text to the screen is a side effect.
  • alert(“Hello, World!”);
  • console.log(Math.min(2, 6, 28));
  1. When your program contains more than one statement, the statemens are executed in order one by one.
  2. Program can execute the command only if the condition is fulfilled.
  3. if, else, else if
1 Like

An expression is any fragment of code that produces a value. I like to think of it as a thought. Once you think of something it means somethin.

A binding is something that connects to an expression for the cpu. It helps the cpu categorize the expression (thought) ex: var one=1

An environment consists of all the expressions and functuin in which a program exists. This includes the background functions that are in default a part of a browser

A function is a background program that is a part of an environment. The definition is a piece of program wrapped in a value. I guesse its what makes javascript what it is and how it differs from other programs

Console.log is a function

A side effect is a change that occurs as a program executes.

A function that produces a side effect is <button onclick
A function that produces a value is mathmax

Control flow is the order a program executes

Conditional execution gives alternatives to contrl flow, if and else are keywords used to make this happen

1 Like

What is an expression?

  • A fragment of code that produces a value is called an expression

What is a binding?

  • A binding gives two expressions the same state. The special keywords “let, var and const” define the name of the binding to an expression. Now the name and the expression(a value or an operation of values) are connected to each other.

What is an environment?

  • a collection of bindings that exists at a certain time.

What is a function?

  • a function is a specific task to handle expressions and bindings that can be invoked multiple times.

Give an example of a function.

  • setTimeout() is a standard function

What is a side effect?

  • showing a dialogbox or changing something on the screen is called a side-effect.

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

  • side effect: document.write(“hello Ivanontech”)
  • value: (new Intl.NumberFormat(‘nl-NL’, { style: ‘currency’, currency: ‘EUR’ }).format(amountOfBitoin * exchangeRate));

What is control flow?

  • when the statements are executed from top to bottom is called “control flow”

What is conditional execution?

  • when a certain condition is not fulfilled, a program can skip the execution and move on to the next part of the program

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

  • The “if” statement sometimes in combination with “else if” and/or “else”
1 Like
  1. An expression is “A fragment of code that produces a value…” - Eloquent JavaScript
  2. A binding or variable holds a specific defined value.
  3. “The collection of bindings and their values that exist at a given time is called
    the environment.” - Eloquent JavaScript
  4. “A function is a piece of program wrapped in a value. Such values can be applied
    in order to run the wrapped program.” - Eloquent JavaScript
  5. alert, prompt
  6. A side effect is an additional outcome to invoking a function including it’s return value.
  7. printZeroPaddedWithLabel, zeroPad
  8. Your program must be executed from top to bottom, this is control flow, making sure things are executed in the proper order.
  9. “…where the program takes the proper branch based on the situation at hand.” - Eloquent JavaScript
  10. if is the keyword used to create conditional execution.
2 Likes