Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?

A fragment of code that produces a value is called an expression, no matter if the value is given literally or combined by operators. Expression can contain other expressions.

  1. What is a binding?

Bindings hold values for later use. By using the word ‘let’ we create binding by giving it a name and/or expression.

  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/called in order to run the wrapped program.

  1. Give an example of a function.

prompt(“Enter passcode”); the binding prompt holds a function that shows a little dialog box asking for user input.

  1. What is a side effect?

When a statement change the internal state of the machine or in a way that will affect the statements that come after it, not just holding a value but displaying it on the screen or saving it into a database. These changes are called side effects.

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

Value
x = Math.max(2, 4);

Side effect (the output of the value in console/computer screen)
console.log(Math.max(2, 4));

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

  1. What is conditional execution?

Not a straight control flow. We may, for example, want to create a branching control flow, where the program takes the proper branch based on the situation at hand. This is called conditional execution.

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

if

2 Likes
  1. A fragment of code that produces value
  2. To catch and hold value using the keyword “let” and then a variable.
  3. The collections of bindings and their values existing at a given time.
  4. A piece of program wrapped in a value.
  5. A block of code design to perform a particular task. A dialog box asking for user input.
  6. A returned value such as a dialog box
  7. Writing text on the screen and Math.max function.
  8. Multiple statements being executed like a story, from top to bottom.
  9. Code executed only if certain conditions hold.
  10. "if’
2 Likes
  1. an expression is a fragment of code that produces a value
  2. a binding is a statement that lets the system remember the internal state you created with your previous lines of code
  3. an environment is a collection of bindings (the ones the programmer have created as well as the in-built ones from the language itself)
  4. a function is a piece of program wrapped in a value
  5. an example of a function is a pop-up window (or “prompt”) that asks the user to input something
  6. a side effect is something that changes in “the world” (on on the screen for instance) as a result of internal changes the programmer has made with code, to the internal state of the machine, the writing of a state that lives beyond the execution period of the function.
  7. Side effect function: API Calls or HTTP requests
    Function that produces a value: adding two numbers together
  8. control flow is the order in which the program reads the statements (top to bottom, left to right, etc)
  9. conditional execution gives the program two or more possible ways of executing, depending on which conditions are met
  10. if
2 Likes

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

2. What is a binding?
Another word for a variable, bindings are used to catch and hold values which need to be used later in the program

3. What is an environment?
A collection of bindings and their values at a given time represent an environment

4. What is a function?
A piece of programming that is wrapped in a value. To invoke a function you reference the value and provide the required parameters in brackets in order to produce the output defined by the function.

5. Give an example of a function.
Prompt(“Enter Password”);

6. What is a side effect?
Any change in state made by a statement. For example, a change to the state of a website or changes which affect the following code

7. Give an example of a function that produces a side effect and another function that produces a value.
No side effect: 2;
Side effect: let userText = prompt(“Enter your name here”);

8. What is control flow?
The order in which statements are executed. JavaScript executes code from top to bottom.

9. What is conditional execution?
A method of altering the path of the program depending on the outcome of if statements. Certain paths are only executed if they meet/do not meet a certain criteria.

10. What kind of keyword do you need to use to invoke conditional execution?
if ( condition to be met )
{ statement to execute if true; }
else if ( condition to be met )
{ statement to execute if first condition is false, second condition is true; }
else
{ statement to execute if neither first nor second conditions are true; }

3 Likes
  • What is an expression?
    an expression is a set of values

  • What is a binding?
    where text can define a value or expression

  • What is an environment?
    a collection of bindings

  • What is a function?
    piece of program wrapped in value

  • Give an example of a function.
    prompt(“hello world”);

  • What is a side effect?
    something that modifies the state of something else.

  • Give an example of a function that produces a side effect and another function that produces a value.
    function that produces side effect - prompt
    function that produces value - Math.max

  • What is control flow?
    The order the code is executed (top to bottom).

  • What is conditional execution?
    a order flow with an IF statement that runs if something is TRUE

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

2 Likes

Good answers, looks like you worked on this for a while. :smiley:

2 Likes
  1. Expressions are fragments of code that produce an outcome, as well as are any values or all operators.

  2. Binding (or variable) is the association mechanism JavaScript uses to generate and hold the values or expressions. It is determined by the expression let followed by the name, the operator = and the expression which will determine the value associated to that binding or variable.

  3. Environment is the collection of bindings and values existing in a given time. When a program starts up, it always has an environment in which it runs.

  4. A function is a piece of code designed to perform a specific task. It can be executed by applying its binding name, followed by parenthesis (you can add values between the parenthesis if you want the program to use it with the function).

  5. Example of function alert;

  6. A side effect is when a function produces an outcome other than a value, which can be useful.

  7. A pop up window can be a side effect and the number written on that pop up the result of the calculation returned by the function.

  8. Control Flow is the execution of the functions is a linear way, from top to bottom, one after the previous.

  9. Conditional execution is the function execution depends on the result of previous inputs.

  10. You need the if keyword to determine if the function will be executed.

2 Likes

Q1. What is an expression?
A fragment of code that produces a value is called an expression. e.g. value of variable, unary operator applied to one expression etc.

Q2. What is a binding?
Binding is also called a variable. It is used by a program to store and hold values during program execution.

Q3. What is an environment?
It is the collection of bindings/variables and their values that exist at a given time of program execution.

Q4. What is a function?
A function is a set of program statements which are executed when invoked with or without value passed to them. The function may or may not return a value

Q5. Give an example of a function.
prompt(“Enter username”); asks for user input
alert(“Hello World”); displays Hello World to the user
parseInt(string) - converts string to Integer

Q6. What is a side effect?
Execution of a statement in a program changes a value, or state of application which affects the statements to be executed after it.

Q7. Give an example of a function that produces a side effect and another function that produces a value.
Side effect - console.log(), prompt(), alert()
Returning value - parseInt(), String()

Q8. What is control flow?
Execution of program statements in the top to bottom order and based on the condition of the program.

Q9. What is conditional execution?
Execution of set of program statements according to the state or condition of the program.

Q10. What kind of keyword do you need to use to invoke conditional execution?
if (condition true){
statement1;
statement2;
}

2 Likes
  1. An expression is a fragment of code that produces a value.

  2. A binding is the same thing as variable, it is assigned a value.

  3. An environment is the list of bindings and their values available at a given time.

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

  5. “alert()” is a function.

  6. A side effect is when an expression changes the internal state of the machine in a way that affects the statements that come after it.

  7. The alert function produces a side effect and the Math.max function produces a value.

  8. Control flow is the reading of the program from top to bottom, left to right like a book.

  9. Conditional execution is when we need the program to branch off in some other way than straight through based on the situation at hand.

  10. Invoke the “if” keyword to invoke the conditional execution.

1 Like
  1. an expression is a line of code that produces a value
  2. a binding is a way to catch and hold old values for the internal state
  3. an environment is collection of bindings and their values that exist at a given time
    4.a function is a peice of program wraped in a value
  4. an example of function ( prompt(“Enter Passcode”); )
  5. side effect is a change that will affect the statements after it
    7.a function that produces a side effect: having an addition function but already stating x=5 before
    function that produces a value: console log(“potato”)
    8.control flow is the order that the instructions or statements or functions are executed
  6. conditional execution is executing the right path in a branched choice based on the situation
  7. Keyword to invoke conditional execution: If / else
1 Like
  1. a fragment of code that produces a value is an expression
  2. bindings, also called variables, catch and hold values to be used later. they create a reference point.
  3. the environment is defined by the collection of bindings and their values at a given point in time.
  4. a function is a set of statements that performs a task or calculates a value. a function takes some input and produces an output where the input and output have some kind of obvious relationship to each other.
  5. console.log is an example of a function. it takes an argument and prints it out to some text output device such as the console in a browser.
  6. a side effect causes an observable change. such as prompt or alert.
    7.prompt(“enter passcode”); produces a side effect
    console.log(math.max(2, 4)); does not produce a side effect. it simply prints out the output 4.
    8.control flow is how the computer exectutes your program(from top to bottom)
    9.conditional functions exectute if certain argument criteria are met.
  7. if
1 Like
  1. An expression is a fragment of code that produces a value.

  2. Binding works like the var function, it allows to assign a value to a sentence.

  3. An enviroment is a collection of bindings and values that are in a program, its like the air that the expressions breathe xp, the enviroment is everything thats inside a program i would say.

  4. I would say that a function is a fragment of code that does something for you, like prompt and console.log do.

  5. Prompt.

  6. It seems thay side effects are the results of a function that doesnt produce a value.

  7. Side effect : Prompt

    Value : Math.max

  8. Control flow is the order in which the commands are executed.

  9. Conditional execution happens when we give a program the ability to choose the right answer depending on the situation that it is in.

  10. The keywords are if and else.

1 Like

Binding, Funcitons and Control Flow Assignment

  1. An expression produces a value, and is like a sentence fragment where the full sentence is a statement.
  2. A binding assigns a value to a variable using var, let, const etc. The assignment is not a box, but like a tenticle that grabs it but can let go and assign a different value.
  3. An envieonment 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. Values can be applied to run the wrapped program. Executing a function called invoking, calling, or applying.
  5. Function examples are console.log, alert("") but also:
    petName(cats, dogs) {
                  console.log("My cat is named "+ cat)
                  console.log("My dog is named " = dog)
    }
    
  6. A side effect is a change in state a function produces that effects the environment.
  7. A side effect: console.log("I am a side effect")
    A value: consolee.log(3*3)
  8. Control flow is the way code is read when there is more than one statement- usually from top to bottom.
  9. Conditional execution is created using "IF" to determine what will happen depending on the condition set.
  10. Conditional executions is invoked using "if"
1 Like
  1. An expression is any code that produces a value.
  2. A binding is a name for a value (mostly referred to as ‘variable’)
  3. An environment is a preset of functions you can use
  4. A function is a set of operations / expressions which is defined in an environment or by the programmer himself
  5. Math.min(4, 5);
    // (will output “4”)
  6. A side effect is a result of an expression / operation that is not visible to the user
  1. let highestNumber = Math.max(10, 42);
    // will bind 42 to the variable highestNumber
  2. console.log("The lowest number is: " + Math.min(40, 52));
    // will output “The lowest number is: 40” to the console.
  1. Control Flow describes that the code is being executed from top to bottom (as expected :smiley: )
  2. Conditional execution makes use of conditions (if and else statements).
  3. “if” shows that a conditional execution is initiated. You may add “else” for the second path or “else if” if you want to add multiple conditions.
1 Like
  1. What is an expression?
    An expression is a fragment of code that produces a value.

  2. What is a binding?
    JavaScript provides a thing called binding, or variable 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 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?
    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(“Your Name“);
    Value example: console.log(Math.max(2, 4));

  8. What is control flow?
    When your program contains more than one statement, the statements are executed as if they’re a story, from top to bottom.

  9. What is conditional execution?
    When we want to create 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?
    Conditional execution is created with the if and else keyword.

1 Like

1values and operaters together makes an expression
2 binding is the connectre between an object to a function
3 functions and values a in the environment
4 command for a specific action
5 count…
6 when a function changes a global variable and then another function reads that global variable, you might not get what you expected
8 control flow refers to the order of executions of the code
9 give a condition for ex if… is treu than execute
10 if or when x>y than

1 Like
  1. A fragment of code that produces a value is called an expression.
  2. Binding is another word for 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. prompt(“Enter passcode”);
  6. A side-effect makes a change to the environment.
  7. console.log produces a side-effect, math.max produces a value.
  8. Control flow is the order in which statements are executed.
  9. Conditional execution is where control flow is based on the
    situation at hand.
  10. Conditional execution is created with the if keyword in JavaScript.
1 Like
  1. An expression is a piece of code that produces a value.
  2. A binding holds a value, also called a variable.
  3. An environment is a collection of variables at a given time.
  4. A function is a piece of program wrapped in a value that does something useful.
  5. alert (“Make coffee before starting”)
    6.A side effect is any result of a function that does not produce a value.
  6. alert (“Make coffee before starting”) produces a side effect,

function arrayAverage (arr) {
var sum = 0;
for (var i in arr) {
sum += arr [i];
}
var numbersCnt = arr.length;
return (sum / numbersCnt);
}
var arr = new Array(9, 27, 45, 99, 12, 11);
var avg = arrayAverage (arr);
console.log(avg); produces a value.
8. Making a program act differently based on supplied values.
9. Using keywords to branch how a program produces a value.
10. “if” and “else”

1 Like
  1. What is an expression?
    A: A fragment of code that produces a value
  2. What is a binding?
    A: Binding is a variable. Binding is a way a program keeps an internal state. Binding stores value so that we can use it later.
  3. What is an environment?
    A: The collection of bindings and their values that exist at a given time.
  4. What is a function?
    A: a piece of program wrapped in a value
  5. Give an example of a function.
    A: prompt(“Enter passcode”);
  6. What is a side effect?
    A: 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.
    A: side effect-- prompt(“Enter passcode”);
    value–console.log(Math.max(2, 4));
  8. What is control flow?
    A: the order in which a program will execute the code
  9. What is conditional execution?
    A: where you create 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?
    A: “If” if a condition is true;
    “else” if the same condition is false;
    “else if” for a new condition to test if the first is false.
1 Like
  1. A fragment of code that produces a value is called an expression.
  2. A binding or a variable catches and holds values.
  3. A collection of binding and their values at a given time is called an environment.
  4. A function is a piece of program wrapped in value.
  5. console.log()
  6. Any effect that changes the state of the world, such as writing text to the screen.
  7. a) console.log() b) Math.max(2, 4)
  8. The execution of one statement after the other according to a certain logic.
  9. A program executes on the condition of a certain situation being met or not.
  10. if
1 Like