Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression? A code fragment producing a value

  2. What is a binding? A piece of code which ascribes values. After a binding has been defined, its name can be used as an expression.

  3. What is an environment? Collection of bindings with corresponding values at a given time.

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

  5. Give an example of a function. For example a prompt function - prompt(“enter password”); - which opens a box inside a browser asking for the user’s input

  6. What is a side effect? An effect which an expression has on the functionality of others within the program

  7. Give an example of a function that produces a side effect and another function that produces a value.
    prompt(“enter password”); creates a side effect in form of a dialogue window
    console.log(Math.max(2, 8) + 400);
    // → 408 (the value returned)

  8. What is control flow? It is an order in which statements and their functions are executed. They go from left to right, top to to bottom, as if reading a book.

  9. What is conditional execution? If the straight road of execution does not suffice, we can create statements which allow the program to use conditional reasoning to produce values or side effects

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

1 Like
  1. Expression – a fragment of code that produces a value (23 or „psychoanalysis“)

  2. A binding is a value which we bind to a word so that we can recall it in another instance

  3. The collection of binding and their values in a given time is called environment, it is never empty coz some bindings are part of the language standard.

  4. A piece of program wrapped in a value.

  5. Console.log()

  6. Side effects are actions that can change the state of the world.

  7. Alert(“this is an alert buoi”);
    console.log(math.max(4, 8);

  8. Order in which the code is executed, in javascript the order is top to bottom.

  9. When a branching road is created and the program takes the proper branch based on the situation at hand. This is called conditional execution.

  10. For eg. If

1 Like

What is an expression?

A fragment of code that produces a value of code is called expression.

What is binding?

Binding is a method to use when to catch and hold values, binding a object to a common function gives the function different result when it’s need, if you don’t bind it gives the same result or gives an error while the code is executing.

What is an environment?

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

What is a function?

Function is a unit of computation which takes input and produces output.

Give example of a function.

This example calls a function which perform a calculation, and returns the result:

12

Function myFunction(p1, p2){

Return p1 * p2;

}

Document.getElementsByName(“myFunction).innerHTML = myFunction(4, 3);

What is a side effect?

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

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

Side effect:

alert(“alert is a function that produces a side effect”) ;

Value:

Function myFunction(p1, p2){

Return p1 * p2;

}

What is flow control?

Control flow defines the order in which the program statement are executed.

What is conditional execution?

A program with branches, these program takes the right decision based on situation.

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

If and else.

1 Like
  1. An expression is a piece of code that produces a value.
  2. A binding is the storage of a value to a variable. It is called binding to reflect the impermanent and tentacle-like nature of grasping the value.
  3. The environment is the collection of variables and their values at a given time.
  4. A function is a piece of program which produces a value.
  5. function turnToZero(number) {
    return number + -number;
    }
  6. A side effect is a change produced by a function that is not just the value.
  7. alert() produces a dialogue box pop-up containing the passed argument. Math.max() produces a value which is the greatest among the given arguments.
  8. Control flow is the managing of the order of which statements should be run in a program.
  9. Conditional execution is managing of which statements should be run in a program.
  10. To invoke conditional execution, we use “if”, “else if”, and “else” keywords.
1 Like
  1. A fragment of code which produces a value is an expression.
  2. Bindings catch and hold values.
  3. The collection of bindings and values that exist at any given time are referred to as the environment.
  4. A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.
  5. Here is an example of a function - prompt(“Enter name”);
  6. A side effect is a user facing action produced by a function,
  7. Showing a dialog box or writing text to a screen would be examples of side effects
  8. Control flow is used when your program contains more than one statement,
  9. Conditional execution is used for certain code to be executed only if certain conditions are met.
  10. It is created with the if keyword.
    .
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, also called a variable, is a container for catching and holding values.

3. What is an environment? An environment is the 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. prompt(“Enter passcode”);

6. What is a side effect? A side effect is a change that affects the world or affects the internal state of the machine in a way that will affect 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.

function noEffect() {
!false;
}

function sideEffect() {
prompt(“Please enter your Bitcoin address:”);
}

8. What is control flow? Control flow is the order in which code is executed: from top to bottom.

9. What is conditional execution? Conditional execution refers to a program’s ability to execute a statement or sequence of statements only if some condition holds.

10. What kind of keyword do you need to use to invoke conditional execution? Conditional execution is created with the if keyword in JavaScript.

1 Like
  1. A fragment of code that produces a value

  2. binds two values together with keywords and binding names

  3. When you run code on a program that already has specific rules or codes already put in. The bindings and values that exist at a given time

  4. a piece of program wrapped in a value

  5. yourName = prompt(“Who are you?”);

  6. If a statement or expression alters something in the program

  7. value: let number = 0; while (number <= 24) { console.log(number); number= number+1; }

    side effect: yourName=prompt(“Who are you?”);

  8. The program will run the code like telling a story, top to bottom.

  9. If you want to create a branching road in a situation

  10. “if”

1 Like
  1. A piece of code (fragment/string) that generates a value.
  2. Same as variable. Connects a value and a name.
  3. An environment is a cluster of bindings with actual values. Can be given at any time.
  4. A function is a piece of code that uses some standards to generate some value out of a set of variables.
  5. var a = “Hello”; var b = “World” alert(a + " " + b);
  6. A dialogue box or text to the screen.
  7. prompt(“test)”
  8. The flow of the program-reading. Top to bottom.
  9. This is a function that allows the program to execute parts of the code, if a statement agrees with a specific condition.
  10. For example: IF.
1 Like

6. What is a side effect?

Hello sir, quite close, just to give you a better understanding:

  • The operation of a function, will produce a result, that result is the side effect.
  • So a side effect is the result produced by a function operation.

Hope this gives you a clear view of the subject, keep learning! :slight_smile:

Carlos Z.

1 Like
  1. What is an expression?
    A fragment of code that produces a value, like 2+3 or a-57.
  2. What is a binding?
    A binding (or variable) is a placeholder for a value, object or function.
  3. What is an environment?
    The collection of bindings and their values that exist at a given time. There is always a default environment with bindings to standard or built in funktions and objects.
  4. What is a function?
    A function is a piece of program wrapped in a value. It’s basically a piece of code that does something.
  5. Give an example of a function.
    The + operator is a funktion, and so is the console.log() function.
  6. What is a side effect?
    A change to the state of the machine or program produced by a statement.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Console.log() produces a side effects, and the + operator produces a value.
  8. What is control flow?
    It’s pieces of code that makes the execution of the program take different routes, do different things depending on a condition.
  9. What is conditional execution?
    It’s execution of code depending on a condition.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If, else, else if, and there’s also the switch/case execution.
1 Like
  1. Fragment of code that produces a value.
  2. Keywords used to catch and hold values.
  3. Collection of bindings and values that exist @ a given time.
  4. A piece of program wrapped in a value.
  5. console.log
  6. Showing dialog box or writing text to the screen.
  7. console.log(side effect) Math.max(value)
  8. Program containing multiple statements is executed like a story from top to bottom.
  9. Program execution re-routes dependent upon certain conditions.
  10. if
1 Like
  1. piece of code that as an result outputs value. One expression can hold multiple expressions in itself. Because of that we can build expressions that describe complex computations.
  2. Binding stores value. It is done with “let” and “var”. That allows us to bind certain values to combination of words of our choice so we can use them later instead of typing/remembering the value.
  3. Collection of values and their bindings that exist at a given time.
  4. Function is a piece of program wrappend in a value.
  5. prompt(“Your password”);
    Alert(“Just HODL”)
  6. Showing dialog box or writing text to the screen.
  7. Side effect ex: promt(Your password)
    Value example: console.log(5+5)
  8. Control flow is the order in which functions, statements etc. are executed.
  9. Conditional execution is when the program executes only some statements or functions which are appropriate for a given situation.
  10. IF, (else?)
1 Like
  1. A fragment of code that produces a value for example: x = 1
  2. In a program, a binding is the declaration of an expression to a value. This binding can later be used to call its value.
  3. An environment is the state of all bindings at a given state of the program
  4. A function is a set of statements that calculate a value from an input
  5. Example of a function:
    function square(number){return number*number}
  6. A side effect is the modification of the outside word by running a function
  7. console.log produces the side effect of displaying a value on the console and the answer to question 5 is an example
  8. A control flow is the order in which a program is running such as a linear/straight control flow
  9. A conditional execution is the modification of the control flow of a statement depending if a particular condition is met or not. The control flow is thus not linear and has many paths.
  10. The necessary keyword for conditional execution are: if and else
1 Like

Hello sir, the ELSE statement can only be applied after the IF condition, it work like this “if something happens, do this, everything else, do this”, you cannot use the else without the IF first.

Hope this gives you a clear view of the subject, keep learning! :slight_smile:

If you have any doubt, please let us know so we can help you!

Carlos Z.

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

  2. What is a binding?

JS’s way of capturing and holding values. Expressions and values are tethered to variables to allow for a more versatile programming language.

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

  2. What is a function?
    “A piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.”

  3. Give an example of a function.
    prompt(“Enter passcode”);
    -or-
    function addOne (number) {
    var sumOfFunction = number + 1;
    return sumOfFunction;
    }

  4. What is a side effect?

A side effect allows for a dialog box or text to be displayed on screen as a result of executing a function.

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

Not clear on the difference between side effect and another function that produces a value. I thought both produce values as the result of executing of the function. I can imagine that the only difference would be that the side effect is something like a dialog box or text along with the value.

  1. What is control flow?

The order in which the code is executing and which way the orders of execution flow.

  1. What is conditional execution?

A conditional execution allows the creation of branching roads in a program using the if keyword.

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

if

1 Like

6. What is a side effect?

  • The operation of a function, will produce a result, that result is the side effect .
  • So a side effect is the result produced by a function operation.

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

For a function with a side effect that produce a value, you already figure it out in the question 5:

function addOne (number) {
 var sumOfFunction = number + 1;
 return sumOfFunction;
}

For a function that only produce a side effect:

console.log(sumOfFunction);

The difference? the 1st one will take a parameter and operate with it and produce a different vale. The 2nd one will only show in the console what is the value of the variable. Both produce a side effect but in a different way.

Hope this gives you a clear view of the subject, keep learning! :slight_smile:

Carlos Z.

Oh yes, thank you Carlos! I watched all of the youtube videos that Ivan linked and it really helped me, now I actually understand everything thats going on! :smiley:

1 Like
  1. An expression is a fragment of code that produces a value.
  2. Binding is used to catch and hold values.
  3. The environment is a collection of bindings and their values that exist in a given time.
  4. A function is a piece of program wrapped in a value.
  5. Example: In a browser environment a little dialog box asking for user input.
  6. Side effects are produced by some functions.
  7. “prompt” is a function that produces a side effect. “Math.max” is a function that produces a value.
  8. When a program contains more than one statement. The statements are executed from top to bottom.
  9. When we want some code to be executed if a certain condition holds.
  10. With the “if” keyword in JavaScript.
1 Like
  1. What is an expression?

A fragment of code that produces a value.

  1. What is a binding?

Binding is the action used by JavaScrip to catch and hold values. By typing the word “let” which indicates that the following sentences will define a binding. It is followed by the name of the binding, the operator " = " and the expression to bind. Such as ( let bindingName = expression; )

  1. What is an environment?

An enviroment is a collection of binding and their values that exist at a given time.

  1. What is a function?

A function is a piece of program wrapped in a value which can be applied in order to run the wrapped program.

  1. Give an example of a function.

prompt(" Write something ");

  1. What is a side effect?

A side effect is that which produces a change in the world such as displaying something on the scree.

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

alert(“Hello World”)

  1. What is control flow?

Control flow is the order in which statements are executed, from top to bottom.

  1. What is conditional execution?

Conditional execution is used when we want to create a branching road, where the program takes the proper branch based on the current situation.

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

" if " " else "

1 Like
  1. an expression is set of literals, variables, operators, and or expressions combined to reach a certain value.
  2. a binding is the value given to any given string via certain keywords (let , var, const, etc.)
  3. the collection of values and their bindings that exist withing a program.
  4. A program that is wrapped inside a value.
  5. Prompt (“what is your name”)
  6. a side effect is code that effects something outside of its own parameters.
  7. a. Prompt(“what is your name”)
    b. console.log(Math.max(2, 4));
  8. Control flow is the direction the program needs to flow in order to be fully executed when there is more than one statment.
  9. if and else keywords are used to execute if certain conditions hold.
  10. if and else.
1 Like