Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?
    A fragment of code that produces a value and used to inspect and process strings of data.

  2. What is a binding?
    They are the connectors to values, but are not the values themselves, therefore multiple bindings can connect to the same value. Bindings need to be connected to some value.

  3. What is an environment?
    It is the collection of bindings and values accessible to Javascript at any given time.

  4. What is a function?
    It is a wrapped set of values organized in such a way so that they run as a computer program.

  5. Give an example of a function.
    console.log(Math.min(2, 4) + 100); (This is useful and might save me using excel sometimes just to find the smallest number of a large list)

  6. What is a side effect?
    It is an expression that could have an effect on future expressions produced by a computer program i.e.) the original expression resides on the computer.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log(“Hello!”); (returns the value undefined, but prints the side effect hello)

  8. What is control flow?
    Where a computer program processes statements in the order they appear in the program however, the flow can be branched depending on the code.

  9. What is conditional execution?
    Using the if keyword in Javascript determines which branch the processing of code will follow.

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

1 Like

Great answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

1 Like

What is an expression?
It is a fragment of code that will use values and operators to get another value.

What is a binding?
A binding is synonymous with a variable that is like the same thing as a storage place for values in a program but the binding doesn’t really store the value like in a box, it only in a way hold on to a value.

What is an environment?
A place where some bindings and values are sitting together at a specific moment.

What is a function?
My understanding is that they also are a kind of value where code is wrapped inside the value, that value (function) is then also using a binding for when someone might want to invoke the function through using the binding to find it.

Give an example of a function.
console.log(“Hello”);
This function will output the word “Hello” to the console in the browser.

What is a side effect?
When a statement changes the internal state of the program so that other statements inside it will become affected.

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

functionSideEffect(x) {
  If(x > 5) {
    variableA = "Hi!";
  }
  else {
    variableA = "Goodbye!";
  }
}
functionValue(x) {
  return x + 1;
}

What is control flow?
It is the flow which the statements are executed throughout the program, oftentimes starting from the top of the code and executing row after row downwards.

What is conditional execution?
It is when one controls the flow of the program with conditions to be met for the program to choose one branch over another branch in the program.

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

1 Like
  1. Expresion is a fragment of code that produces a value. It is a part of statement
  2. Binding is a thing that catches and holds values
  3. Enviroment is a collection of bindings and their values that exist at a given time
  4. Function is a piece of program wrapped in a value.
  5. prompt(“how am I doing?”)
  6. It is showing a dialog box or writing text to the screen
  7. side effect:
    prompt(“anything”)
    function that produces a value:
    console.log(math.max(2, 4));
  8. if we have more than one statement, they are executed from top to bottom
  9. it is when we want to create branches of excecution…not a straight line like control flow.
  10. if, else
1 Like
  1. A piece of code that resolves to value
  2. Binding stores value so we can use it later
  3. An environment is set of variables and their values that exist in memory at a given time.
  4. A function is named section of a program that performs a specific task.
  5. console.log (")
  6. A dialogue box or writing text to the screen is a side effect.
  7. function addFive(value){
    return value+5;
    }
  8. The order in which statements are executed.
  9. This is where the program takes the direction based on the situation at hand.
  10. if, else
1 Like

What is an expression?

A fragment of code that produces a value.

What is a binding?

A binding is also known as a variable. It is created to catch and hold values by using the keyword let to define the binding. A binding can also be used as a value. You can also use var and const to create bindings, in a similar way to let. A binding name must not start with a digit, but can contain digits. A binding name can contain a $ or _ but no other puncutation or special characters and must not use keywords (reserved words).
Example:
let answer = 2 * 4;
console.log(answer + answer);
// -> 16
var name = “John”;
const greeting = "Hello ";
console.log(greeting + name);
// -> Hello John

What is an environment?

It is the collection of bindings and their values at a certain point in time. When a program starts the enivronmnt is not empty because it will contain bindings that are part of the language standard, and some bindings for interaction with surrounding system (eg browser, mouse, keyboard input).

What is a function?

A piece of program wrapped in a value. You can then apply the value to run the wrapped program.

Give an example of a function.

prompt(“Enter email address”);
print(); (opens the print dialog box)

What is a side effect?

These are changes caused by running the program. They do something that affects the world, after they have happened, for instance, displaying something ont the screen or changing an internal state in the computer that affects the statements that come after this statement eg, prompt example above, displays on the screen and the person interacting with it enters an email address.
Some functions are used for their side effects, whilst other are used for their return value.

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

prompt (“Enter email address”); the prompt function produces the side effect of a dialog box appearing.

Math.min(1,-46,57,953,0,0.123); produces the side effect of the value -46

What is control flow?

It is the order in which statements are executed when a program contains more than one statement. Statements are executed top to bottom as if you were reading a story. So the control flow is the journey path through the statements and program. It can be a single path or branching path.

What is conditional execution?

Not all control flows are straight, sometimes you may need a branch. The branching is known as a conditional execution, because it depends on the situation in hand. For example you may want a user to put in a number for a calculation, but if they don’t, the program can hold an alternative path informing them they did not provide a number.

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

if
if … else

1 Like
  1. An expression is a fragment of code that produces a value.
  2. “Tentacles” that attach to a value and hold onto it. You can use for e.g. the let statement to define bindings.After a binding has been defined, its name can be used as a expression.
  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. In a browser the binding alert() invokes a function that shows a pop up alert box.
  6. A side effect is a statement or function that an user interact with.
  7. For e.g prompt() results in a side effect, which is a dialogue box, while the math.max() produces only a value.
  8. The control flow is the order in which the code is executed.
    9.Conditional execution is created with the if keyword. In the
    simple case, we want some code to be executed if, and only if, a certain condition
    holds.
1 Like
  1. An expression is a piece of code that produces a value.
  2. A binding binds a value to a word. Bindings are important, because they are a way of remembering outcomes of expressions or statements.
  3. The environment is the collection of currently existing bindings and their values.
  4. A fucntions is a piece of code wrapped in a value. Instead of having to type the whole code repeatedly you can use the value (name of the function) and perform the operation with the function.
  5. function avarageof2 (a,b) {return (a+b)/2;};, console.log, alert
  6. a side effect is every effect of code which leads to changes ourside the current statement. - Totally not sure!
  7. side effect: alert, avarageof2 (see 5)
  8. When code is executed, it is executed from left to right and top to bottom.
  9. Conditional executation happens when the piece of code to execute is chosen on basis of the current state, e.g. if a variable has a certain value it choses one way, and if it has another value it choses another piece of code.
  10. if
1 Like
  1. What is an expression?
    Expression is a fragment of code that produces a value.

  2. What is a binding?
    In other words, bind () method allows us to easily set which object will be bound by the this keyword when a function or method is invoked. After a binding has been defined, its name can be used as an expression.

  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.

  4. What is a function?
    JavaScript a function allows you to define a block of code, give it a name and then execute it as many times as you want. A function can be defined using function keyword and can be executed using () operator. A function can include one or more parameters

  5. Give an example of a function.

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

Output of a function is 15.

  1. What is a side effect?
    If you give variable “x” a value in global scope but use x in your function then it will have side effect on your function.
  2. Give an example of a function that produces a side effect and another function that produces a value.
    Pure function is produces a value:
    const identity = (x) => x;
    identity (4) //4
    identity (3) //3
    identity (2) //2
    identity (1) //1

Side effect produces:

let x = 0;
undefined
const increment = () => {
x = x +1;
console.log(“hello, I’m side effect”)
return x;
}
undefined
increment()
hello, I’m side effect
1
increment()
hello, I’m side effect
2
increment()
hello, I’m side effect
3

  1. What is control flow?
    The control flow is the order in which the computer executes statements in a script and executed as if they are a story, from top to bottom.

  2. What is conditional execution?
    Program decides to either execute function or not, IF expression is correct or not.

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

1 Like

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

  1. What is an expression? - Its a fragment of code that produces value
  2. What is a binding? - Its a function that lets you catch and hold values
  3. What is an environment? - ITs the collection og bindings and their values that exists in that particular time in the code
  4. What is a function? - It is a piece of program wrapped in a value. This values can be applied to run such programs
  5. Give an example of a function. - prompt(“enter your private keys and trust me. mwahahaha”)
  6. What is a side effect? - It is things that happens after you execute a piece of code that executes the side effects. Like the “alert” command gives a side effect when the new box appears
  7. Give an example of a function that produces a side effect and another function that produces a value. - The alert command produces a side effect and console.log(Math.min3 , 8) + 50); produces value
  8. What is control flow? - Its the order of the statements in the program
  9. What is conditional execution? - It is something you can use to create alternatives so the program can choose different alternatives based on the situation at hand
  10. What kind of keyword do you need to use to invoke conditional execution? - let, 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 is a variable like a tentacle that grasps a value.
  3. What is an environment?
    an environment is a collection of binding and there values.
  4. What is a function?
    a function is a piece of program wrapped in a value.
  5. Give an example of a function.
    promt (“enter password”)
  6. What is a side effect?
    the showing of a dialog box or writing text to a screen
  7. Give an example of a function that produces a side effect and another function that produces a value.
    promt and let
  8. What is control flow?
    control flow is the way statements are executed like a book top to bottom.
  9. What is conditional execution?
    conditional execution is if we want some code to be executed if and only if a certain condition holds true.
  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 a value, including values that are written literally. Expressions can contain other expressions.
  2. A binding is a variable. It holds a defined value and can be used as an expression. Examples are “let” “var” and “const”
  3. An environment is a collection of bindings and their values.
  4. A function is a program wrapped in a value.
  5. alert(“hello world”) is an example of a function.
  6. A side effect is a returned statement that affects statements that follow.
  7. An example of a function that produces a side effect is prompt(“enter name”) and a function that produces a value is (3+5)
  8. Control flow is the order that a computer executes statements in a script. In Javascript, the computer executes from top to bottom.
  9. Using “if” function pre-determined different outcomes occur depending on the input.
  10. “If” function is the keyword used to invoke a conditional execution.
1 Like
  1. A fragment of code that produces a value
  2. JS’s way of catching and holding values. Also known as a variable
  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. The binding prompt holds a function that shows a little dialog box asking for user input
  6. A change in the internal state of a machine in a way that will affect the statements that come after it is deemed side effect–Showing a dialog box or writing text to the screen is a side effect
  7. The function Math.max takes any amount of number arguments and gives back the greatest.
    console.log(Math.max(2, 4)); // → 4
  8. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom
  9. Created by the IF keyword. It is used when we want some code to be executed if, and only if, a certain condition holds
  10. IF and ELSE
1 Like

Welcome to the discussion about the reading assignment about Binding, Functions and Control Flow.

Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

  1. What is an expression?
    A fragment of code that produces a expression
  2. What is a binding?
    A tentacle grasp to catch and hold values
  3. What is an environment?
    A collection of bindings and there 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.
    The binding prompt in a browser
  6. What is a side effect?
    Showing a dialog box or writing text to a screen
  7. Give an example of a function that produces a side effect and another function that produces a value.
    **side effect: console.log produces a side effect
    Value: c=3 **
  8. What is control flow?
    When your program contains more then one statement, the statements are executed from top to bottom
  9. What is conditional execution?
    A branching road where the program takes the the branch based on the situation at hand
  10. What kind of keyword do you need to use to invoke conditional execution?
    if/else
1 Like

@jostrings

let is used to create a variable :wink:

1 Like
  • What is an expression?
    Any code that can be resolved to produce a value

  • What is a binding?
    A variable with a name that links to a value

  • What is an environment?
    A collection of bindings and their values

  • What is a function?
    A piece of code wrapped in a value that can be applied in order to run the program

  • Give an example of a function.
    An example would be a browser prompt to enter a password

  • What is a side effect?
    A side effect is anything that produces a visual result by executing a function, such as a dialog box or screen text

  • Give an example of a function that produces a side effect and another function that produces a value.
    Side effect - dialog box
    Value - a numerical return of a mathematical problem

  • What is control flow?
    Control flow is the logical execution sequence of statements from top to bottom

  • What is conditional execution?
    The execution of a program based on pre-defined parameters being met

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

1 Like

1 resolves to a value
2 being stored to memory
3 The enviroment is the collection of bindings and their values existing in a given instance.
4 an expression wrapped in a value
5 alert message
6 A dialogue box or writing text to the screen is a side effect.
7 console.log produces side effect and Math.max produces a value.
8 Is the order in which individual statements, instructions or function calls of an imperative program
are executed or evaluated.
9 is a function that allows the program execute some code if the statement provided agrees with the condition.
10 if let const

1 Like

Ahhh. THx man. Love your Passion!!!

1 Like