Binding, Functions and Control Flow - Reading Assignment

  • What is an expression?
    An expression is a fragment of code that produces a value. Every value that is written is an expression. An expression between two parenthesis is also an expression. Expressions can contain other expressions.

  • What is a binding?
    A binding is a way in JavaScript to catch and hold values. You can use Var (Variable); Const (Constant) or Let. When a binding points to a value, it does not mean that its tied to that value forever - = will break it.

  • What is an environment?
    An environment is a collection of bindings and their values that exists at a given time.

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

  • Give an example of a function.
    prompt
    math.max
    math.min

  • What is a side effect?
    A side effect is a statement that has an affect either by producing something on screen or changes the internal state of the machine in a way that affects the statements that come after it.

  • Give an example of a function that produces a side effect and another function that produces a value.
    Example of a function that produces a side effect, is prompt - this function will create a dialog box (which is the side effect).

Example of a function that produces a value is math.max - this function will produce a value (which is the side effect).

  • What is control flow?
    A control flow is the order in which a program is executed when it has more than one statement - top to bottom.

  • What is conditional execution?
    A conditional execution is when we cause a code to be executed only if a certain condition is present. - If, else, switch are examples.

  • What kind of keyword do you need to use to invoke conditional execution?j
    If, else, switch

[/quote]

1 Like
  1. What is an expression?
    combination of vales and objectives

  2. What is a binding?
    its a tool allows to catch and hold a value

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

  4. What is a function?
    its a piece of code for specific task

  5. Give an example of a function.
    function sum(a,b) {
    return a + b;
    }

  6. What is a side effect?
    its a visible result produced by function

  7. Give an example of a function that produces a side effect and another function that produces a value.
    function sum(a,b) {
    return a + b;
    }
    function Math.max(1,3,5,88);

  8. What is control flow?
    when program execute one statement after another

  9. What is conditional execution?
    when program has to chose what execution suppose to happened based on particular data and situation

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

1 Like
  1. A fragment of code that produces values and applied operators to them to get new values.
  2. Catching and holding values.
  3. A space where a collection of bindings and their values exists at a given time.
  4. A piece of program wrapped in a value.
  5. prompt(“How many coins would you like to buy?”);
  6. A dialog box or writing text to the screen.
  7. console.log(Math.max(2,4));
    console.log(Math.min(2,4) + 100);
  8. A program that contains more than one statement
  9. A program that takes the proper branch based on the situation at hand.
  10. if
1 Like
  1. Expression: A fragment of code that produces a value is called an expression.
  2. imagine bindings as tentacles, rather than boxes. They do not
    contain values; they grasp them—two bindings can refer to the same value. ex: let caught = 5 * 5;
  3. The collection of bindings and their values that exist at a given time is called the environment.
  4. Function: A function is a piece of program wrapped in a value.
  5. Ex: prompt(“Enter passcode”); console.log(Math.min(2, 4) + 100);
  6. Side Effect: Showing a dialog box or writing text to the screen is a side effect. Also, it can produce values.
  7. See 5.
    8.Control Flow: program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
    9.Conditional Execution: create a branching road, where the program takes the proper branch based on the situation at hand.
  8. if
1 Like
  1. An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value.

  2. Binding something in JavaScript means recording that identifier in a specific Environment Record . Each Environment Record is related to a specific Execution Context - and that binds the identifier (variable or function name) to the this keyword for that execution context.

  3. Arguments are values passed to the function when it is invoked.

  4. A function is a block of code designed to perform a particular task. A JavaScript function is executed when something invokes it (calls it).

  5. Example of a function

function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2
}

  1. A side effect is when we change the state of the program through an indirect means.

function (objectArgument) {
objectArgument.value += 123;
return objectArgument;
}

  1. The control flow is the order in which the computer executes statements in a script.

  2. Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run.

  3. a) Use if to specify a block of code to be executed, if a specified condition is true.
    b) Use else to specify a block of code to be executed, if the same condition is false.
    c) Use else if to specify a new condition to test, if the first condition is false.
    d) Use switch to specify many alternative blocks of code to be executed.

1 Like
  1. Fragment of code that produces value is an expression
  2. Binding is part of the code where certain variable is being assigned a value
  3. The collection of bindings and their values that exist at a given time is called environment
  4. A function is a piece of code wrapped in a value
  5. Console.log; math.max; math.min
  6. Changes to the environment made by expressions are called side effects
  7. Fx producing side effect: let ten = 10; Fx producing value: console.log(Math.max(1,2))
  8. Control flow is the direction in which statements are executed: straight-line, conditional
  9. Conditional execution means the code will be executed at particular point when specific condition is met
  10. To invoke conditional execution, we use if keyword, could be together with else
1 Like
  1. What is an expression?

A fragment of code that produces a value.

  1. What is a binding?

How javascript catch and hold values

  1. What is an environment?

A collection of bindings and their values that exist at any given time

  1. What is a function?

A piece of program wrapped in a value

  1. Give an example of a function.

Prompt(“enter password”)

  1. What is a side effect?

A side effect is any application state change that is observable outside the called function other than its return value. eg. Showing a dialog box or writing text to a screen

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

Side effect

var tax = 20;

function producing a value

Console.log(Math.min(2, 4) + 100);

  1. What is control flow?

When your program contains more than one statement, where each statement is executed in order top to bottom in a sequence like a story.

  1. What is conditional execution?

instead of 2 straight roads, program takes a branching road where program takes the proper branch based on the situation at hand using the “if” keyword.

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

If or else

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

  2. Bindings hold values.

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

  4. Piece of program wrapped in value.

  5. alert(“Hello”);

  6. When a function returns a value or change the state of an expression.

  7. prompt (“Enter number”);

    console.log(math.max(2, 4));

  8. The path of how the programs will be executed.

  9. That is like a split in the path. You can go different way based on the conditions.

  10. If, else, if else.

1 Like
  1. What is an expression? A pice of code that produces a value is an “expression”.

  2. What is a binding? Binding is when the code catch and hold values.

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

  4. What is a function? It is a piece of grogram wrapped in a value.

  5. Give an example of a function. - alert ( “Enter passcode” );

  6. What is a side effect? A side effect is a function which produces an expression and returns that value.

  7. Give an example of a function that produces a side effect and another function that produces a value. - prompt ( “Enter passcode” );

  • console.log (Math.max (22,5,9,13) );
    22
  1. What is control flow? It is when you program contains more than one statement, the statements are ececuted as if they ara a story, from top to bottom.
    ex.
  • let theNumber = Number(prompt(“Pick a number”));
    console.log("Your number is the square root of " + theNumber * theNumber);
  1. What is conditional execution? For example when you create a branching road, where the program takes the proper branch based on the situation at hand.

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

1 Like

What is an expression?
a portion or fragment of cosed that produces a value
What is a binding?
Is a way of holding values against a name or number, the name or number can then be used in an expression to represent the value that is bound to it.
What is an environment?
A collection of bindings and thier values at any given time
What is a function?
A function is a piece of program wrapped in a value, the values can then be applied to execute a program.
Give an example of a function.
A prompt that appears on a website asking for a username and password
What is a side effect?
The action of showing a dialog box or writing a text message on the screen
Give an example of a function that produces a side effect and another function that produces a value.
Math.max is a function that produces a value
Writing text on a screen is a side effect
What is control flow?
is the execution of program statements in order
What is conditional execution?
Is the execution of program code in sequence but only once certina conditions have been met.
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.

  2. What is a binding?
    It’s a defined variable which catch and holds values. It is defined by the key word (let).
    After defining it can be used as an expression.

  3. What is an environment?
    It’s a collection of bindings and their values that exists at a given time.

  4. What is a function?
    A piece of program (list of statements) wrapped in a value.

  5. Give an example of a function.
    prompt(“Enter your name”);

  6. What is a side effect?
    These are changes caused by statements which change the internal state of the machine in a way that will affect the statement after it.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log("The square of two is " + (2*2)); //–> The square of two is 4
    console.log(math.max(2, 4)); //–> 4

  8. What is control flow?
    Multiple statements that execute like a story from top to bottom.

  9. What is conditional execution?
    This is a program that branches off to satisfy a set condition, if it holds to the desired criterion.

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

1 Like
  1. An expression is any valid set of literals, variables, operators, and expressions that returns a single value.

  2. A binding or variable is a container for storing data values.

  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. In a browser environment a dialog box is called out by a function contained in the binding prompt.

  6. A side effect happens when a function changes some variables outside of the function.

  7. A function that produces a side effect:
    var a = 12
    function addTwo(){
    a = a + 2; // side-effect

}
addTwo()
A function that produces a value:
const compute = (x, y) => x + y;
console.log (compute (4, 5))
7

  1. A control flow is the order in which the computer executes statements in a script.

  2. Conditional execution is used to decide the flow of the program execution based on different conditions.

  3. To invoice conditional execution the keywords if and else are used.

1 Like
  1. An expression is a fragment of code that produces a value.
  2. To catch and hold values, JavaScript provides a thing called a binding so that the value doesn’t dissipate.
  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. 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.
    7.prompt(“Enter passcode”) has the side effect of opening a dialog box.
    console.log(Math.max(2, 4)); produces no side effect, however, it produces a value.
  7. When your program contains more than one statement, the statements are
    executed as if they are a story, from top to bottom.
  8. Conditional execution is when we want the program to take the proper branch/path based on the situation at hand, based on the current scenario.
  9. Conditional execution is created with the if keyword in JavaScript.
1 Like
  1. An expression is a fragment of code that produces a value.

  2. A binding is a link between a keyword to a value.

  3. The environment is the collection of bindings set in the code that is being worked on/with.

  4. A function is a piece of program that, once executed, produces a value.

  5. alert(“I’m still a noob at this”)

  6. A side effect is the changes made when executing functions.

  7. alert(“side effect”);
    Math.max(1,3,5,7,500};

  8. Control flow is the order our code is executed.

  9. A conditional execution is the execution of specific functions when only certain conditions are met.

  10. Keywords needed to invoke a conditional execution include if and else.

2 Likes

[quote=“ivan, post:1, topic:3069”]

  • What is an expression?
    It is a whole sentence ie values , operators and sum
  • What is a binding?
    It is a variable, It holds values or is available for later use
  • What is an environment?
    It is a collection of bindings and values
  • What is a function?
    A piece of program wrapped in a value
  • Give an example of a function.
    An example is the CAPTCHA where a user interacts with the browser etc to confirm its not a BOT
  • What is a side effect?
    It is an observational tool like the console
  • Give an example of a function that produces a side effect and another function that produces a value.
    A side effect example is the hello world and an eaxample of a function that produces a value is console.log(Math.min(2, 4) + 100);// 102
  • What is control flow?
    Whena program contains more than 1 statement.
  • What is conditional execution?
    The execution is only executed if a certain condition holds. for example if I read a book and it had multiple choice answers and whatever I chose would determine the route the story took.
  • What kind of keyword do you need to use to invoke conditional execution?
    if
2 Likes

Homework on Binding, Functions and Control Flow - Questions August 10, 2020

  1. What is an expression?

A function that produces a value.

  1. What is a binding?

A binding or variable, is a keyword with a special meaning that indicates a statement is going to hold a value such as a expression using the ( = ) operator to store values.

  1. What is an environment?

A collection of bindings, values and statements that exist at a given time.

  1. What is a function?

A piece of program wrapped in a value.

  1. Give an example of a function.

console.log( )

  1. What is a side effect?

Values or statement produced by a function, shown in a dialog box or written on the screen.

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

Side effect: alert(“Side Effect”), Value: console.log(Math.max( 1, 2));

  1. What is control flow?

The order a program executes statements.

  1. What is conditional execution?

Condition execution is when a program executes a statements based on specified boolean objects.

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

The Boolean conditions are if, else if, else.

-Hector A. Martinez

1 Like
  1. An expression results from a code fragment computing a value known as an expression.
  2. A binding is inherently bound to its last known value. This binding can be changed in the following code which will supersede its previous value bond.
  3. An environment is a binding and connecting value that endure.
  4. A function is a program wrapped in a value. eg:
    prompt(“Enter Passcode”);
  5. console.log(Math.max(2, 4));

    4

  6. A side effect happens as a result of a statement. A statement is a constant that stands alone. A side effect is a secondary response to such a statement. It can either effect the outcome displayed in the world, as seen on the web page screen, or within the internal machine itself, which has a definite effect on the statements that come after it. This is what a side effect is.
  7. A function side effect produces an on-screen dialogue box. A function that produces a value will display within the console. For example: (3 being the value)
    console.log(1 + 2);

3

  1. Control flow is a program where the succession of more than one statement is being executed.
  2. A conditional execution is when a program has to make the best choice between two statements made. With an alternate “if” function path existing, the program will select the one that meets the computational elimination parameters set. For example:

let num = Number(prompt(“Pick a number”));
if (num < 5) {
console.log(“Sml”);
} else if (num < 10) {
console.log(“Med”);
} else {
console.log(“Lrg”);
}

  1. Use the “If” keyword and use the “else” keyword for alternative paths. This program will invoke a conditional execution of best choice.

If(condition 1){
statement block 1
}
else if(condition 2){
statement block 2
}
else{
statement block 3
}

1 Like

1 - A code that produce a value

2 - binding = variable

3 - It’s a collection of bindings

4 - Is an expression wrapped in a value.

5 - Log, prompt etc

6 - is where a function does somethng other that return a value such as writing to the screen

7 - prompt produces a side effect. console.log produces value

8 - Control flow is the sequence in which statements are executed

9 - That occurs when parts of the code is only execyted after a certain condition is met.

10 - IF

1 Like
  1. A fragment of code that produces a value is called an expression
  2. Binding is 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. Such values can be applied
    in order to run the wrapped program
  5. Function X (A,B) {Return A+B};
  6. Showing a dialog box or writing text to the screen is a side effect
  7. Function producing side effect = prompt(“Enter passcode”); and function with no side effect = Function X (A,B) {Return A+B};
  8. The execution of code like a story, top to bottom
  9. The execution based on a condition such as ‘IF statements’
  10. If, Else statements
1 Like
  1. Expression is fragment of code that produces a value, every value that is written literally( number or string) is an expression.
  2. Binding is way a program keeps internal state, it is like tentacle, it doesn`t contain any value but grasp them.
  3. Environment is collection of bindings and their values that exist at given time.
  4. Function is a piece of program wrapped in value, it performs a specific task.
  5. Console.log is used to output the value
  6. Side effect is observable change in the program, like a dialog box or writing text on the screen.
  7. Function that produces side effect: alert(“Hello World”; function that produces a value: console.log(Math.max(2, 4));
  8. Control flow is order in which statements are executed from top to bottom.
  9. Conditional execution is like branch in control flow execution. It is created with keyword if, and if some code wants to be executed it needs to hold certain condition.
  10. If, else, else if
1 Like