Binding, Functions and Control Flow - Reading Assignment

  1. An expression is a piece of code that produces a value.

  2. Binding is the term used when referring to catching and holding a variable.

  3. The environment refers to the state of all bindings and values at a given point in time.

  4. A function is a segment of code wrapped in a value.

  5. An example of a function is prompt()

  6. A side effect is a change of state that is visible outside of the function ie. text on screen.

  7. A function that produces a side effect is prompt() :slight_smile:

  8. Control flow is the order in which code is written and executed.

  9. If/else statements execute a block of code if a defined condition is true/false. They are said to be ‘conditional statements’ because they perform different functions in different environments.

  10. Keywords to invoke conditional execution are if/else.

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

  2. What is a binding?
    This is a way for Javascript to catch and hold values

  3. What is an environment?
    It is the collection of bindings and their values that exists in a particular point in time.

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

  5. Give an example of a function.
    console.log(“text”);

  6. What is a side effect?
    Showing a dialog box or writing text to screen is a side effect.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect: console.log(“text”);
    value: 4+4

  8. What is control flow?
    The order in which your statements are executed.

  9. What is conditional execution?
    It is when we want a piece of code executed only if some condition is met.

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

2 Likes

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 piece of coding that allows a developer to catch and hold values. Bindings are also called variables

3. What is an environment?
The collection of bindings are their values is called the environment

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

5. Give an example of a function
An example of a function frequently used is console.log. The console.log feature allows you to insert information to the console

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

7. Give an example of a function that produces a side effect and another function that produces a value.
An example of a function that produces a value is Math.max. This function will return the greatest number. An example of a function with a side effect is the prompt function this shows a little dialog box asking for a user input

8. What is control flow?
When a program contains more than one statement, the statements are executed from top to bottom.

9. What is conditional execution?
Conditional Execution is where there might be more than one routes to take. It matters from. the situation what code is going to be executed.

10. What kind of keyword do you need to use to invoke conditional execution?
A great example of conditional execution would be the keywords if or else.

2 Likes

Answers:

  1. A fragment of code that produces a value
  2. An element used to catch and hold values (a variable)
  3. The 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. Prompt
  6. Things like showing a dialog box or writing text to the screen.
  7. alert (“This is an alert on a window”) and console.log(30+8)
  8. In a program statements are executed as if they are a story, from top to bottom. This is called control flow.
  9. When using a logical operator to determine if certain parts of the code will be executed
  10. “If”
1 Like

An expression is fragment of code that produces a value

An elemento to catch and hold values, it is a space reserved in memory.

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

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

prompt(“Enter passcode”);

Side effects are changes that change the internal state of a machine or that make display something on the screen.

A function that produces a side effect:
let x = 30;
console.log(“the value of x is”, x);
// → the value of x is 30

A function that produce a value:
console.log(Math.max(2, 4));

It is the way the program flows, if we have more than one statement, the program will execute it from top to bottom.

It is when you have more than one road to take, it happens when you have several statements to execute depending on which condition you are fulfilling.

To invoke them you have to use IF and ELSE.

1 Like
  1. What is an expression? anything (fragment of code) that produces a value
  2. What is a binding? to catch and hold values
  3. What is an environment? collection of bindings
  4. What is a function? programmed wrapped in a value
  5. Give an example of a function. console.log(“helloworld”);
  6. What is a side effect? showing text to a screen
  7. Give an example of a function that produces a side effect and another function that produces a value. alart(“helloworld”);
  8. What is control flow? top down execution of statments
  9. What is conditional execution? outcome/direction of program is dependent scenario
  10. What kind of keyword do you need to use to invoke conditional execution? if else
1 Like
  1. An expression is any type of value, variable, or any type of code that can output or return a value
  2. Binding is attaching a variable to a a value and by that allowing the code to add it to memory.
  3. An environment is the collection of all binding and values that related to the program as soon as it’s start running and used to interact with our webpage or other program.
  4. a function is a wrapped piece of code that perform get an input(s) and print out-puts, or perform any type of task in order to execute more functions.
  5. Give an example of a function.
function reduceTax(INCOME){
   INCOMEAFTAX = (INCOME / 100) * 75;
   return INCOMEAFTAX;
} 
  1. a side effect can occur due to a function, a function out put sometimes can perform a change in the user environment or a webpage appearance. those are some of the example that functions can do other then get or calculate values.
  2. A function that produce a side effect:
function bloodyHell(){
document.body.style.backgroundColor = "red";
} 

A function that produce a value (same as Q 5):

function reduceTax(INCOME){
   INCOMEAFTAX = (INCOME / 100) * 75;
   return INCOMEAFTAX;
} 
  1. Control flow an order of actions or series of statements that will be executed in a flow or order.
  2. Conditional execution is when our code been given more then one boolean options to execute, and they will be asked in a control flow.
  3. ‘If’ or ‘else’
    example:
if (statement1 = true){
return "A"
} 
else {
return "B"
}

1 Like
  1. An expression is a piece of code that expresses a value. An expression produces a value that can then be introduced into the code.

  2. Binding is the attachment of two values which are then produced from the variable.
    ex: John = 30 + 5;
    this would bind (John) to (35).

  3. The environment is a collection of bindings and their values that exist at a given time. For example, programs have environments that are not empty. They have bindings that are part of the language standard. and have bindings to interact with the keyboard / mouse / sound / etc.

  4. A function is a piece of program wrapped in a value. These values can be applied to run the wrapped program. On a browser a prompt would pop up asking for a password or pin code. prompt(“Enter Password”); However, in modern programming these prompts are not used because there is no control over the way the dialog box pops up.

  5. prompt(“Enter your age”);

  6. A side effect is the output of the function. For example the side effect of prompt(“Enter age”); would be the actual dialog box that pops up.

  7. Side effect: prompt(“What is your favorite color?”);
    Value: console.log(Math.min(100 , 200) + 300);
    // 400

  8. Control as is it sounds
 a flow
 or 
 a story. it will produce somewhat of a story. In playing with this I came up with the following:
    theNumber=Number(prompt(“Pick a number”));
    (Enters ‘45’ in prompt)

console.log("Your number is 200% of " +theNumber / 2);
Result = Your number is 200% of 22.5

The Number function will take a value and turn it into a number. Number(prompt
etc
) does this.

  1. A conditional execution would be used when a branching road is desired.
    theNumber=Number(prompt(“Pick a number”)); if (!Number.isNaN(theNumber)) {console.log("Your number is the square root of " + theNumber * theNumber);}
    When this is entered a number must be entered into the text box. Otherwise it will not work because theNumber represents a value executing the program changes it into a ‘number’ to show the desired result of what value (number) that YOUR number is the square root of. If letters are entered into the box it will not compute.

  2. We use the keyword if
    if there is not a number entered so that the program can change it from a value to a number then it will not compute so no output will be ejected.

1 Like
  1. An expression is a syntactic entity in a programming language that may be evaluated to determine its value
  2. Binding is assigning one thing to another, usually, values to variables either by explicit declaration or implicit declaration
  3. An Environment is everything installed on your machine which can affect either the development and or testing of your application
  4. A Function is a set of statements, which is used to perform a specific task or calculate a value
  5. let sayHello = function (‘name ‘) {
    console.log(‘Hello User’);
    }
  6. Side Effect is result of a function that is not its main purpose
  7. Value: Math.max() Side Effect: Console.log(‘ ‘)
  8. The Control Flow is the order in which the computer executes statements in a script
  9. A program is executed depending on the current situation
  10. “if”
1 Like
  1. An expression is a fragment of code that produces a value
  2. A binding points to/grabs a value
  3. The environment is the collection of bindings and their values that exist at a given time
  4. A function is a piece of program wrapped inside a value
  5. An example of a function: the binding “alert” holds a function of creating a pop-up box on a website
  6. Side effects are the visual byproduct of functions, such as a dialog box or text

a) function that produces side effect: alert(“hello”);
b) function that produces a value: 1+1;
8. Control flow is the direction of execution of the program
9. Conditional Execution is where the Control Flow can take a number of different routes depending on the situation at hand/instructions given.
10. The keyword needed to invoke Conditional Execution is “if”

1 Like

What is an expression?
Any fragment of code that produces a value

What is a binding?
Also known as a variable and is a way to capture and store a value for future use

What is an environment?
Set of bindings and corresponding 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.
ï»żconsole.log()
ï»ż
What is a side effect?
ï»żA ny application state change that is observable outside the called function other than its return value. The function interacts with the outside world.
ï»ż
Give an example of a function that produces a side effect and another function that produces a value.
ï»żconsole.log(“Print Me!”); has a side effect and ï»żconsole.log(Math.max(2, 4)); is an example of a function that produces a value with no side effect
ï»ż
What is control flow?
ï»żï»żThe order in which the computer executes statements in a script

What is conditional execution?
ï»żSpecific code is executed if certain conditions are met
ï»ż
What kind of keyword do you need to use to invoke conditional execution?
ï»żInvoke conditional execution in javascript using the ‘if’ keyword

1 Like
  1. Every value that was produced by fragment of code even if it is written literally or between parentheses is an expression.
  2. Binding is a method with which a program catch and hold values. Binding do not contain values it grasp them and hold them in order to use them later.
  3. The collection of bindings and their values that a program has( at a given time ), that are part of the language standard and provide ways to interact with the surrounding system Is called environment
  4. A function is a piece of program wrapped in a value that is applied to run the wrapped program.
  5. An example of a function is “prompt” function which (we usually use it in toy programs and experiments) uses the string that we give it as a text to show in the dialog box, asking for user input : prompt(“Enter passcode”);
    Also console.log is a function that writes out argument to the console.
  6. Side effect is a dialog box or writing text that is showing to the screen, that a faction produce.
    7)a) side effect : prompt(“Enter email”);
    b) value: console.log(Math.max(8, 11))
    //–> 11
    8) control flow is the order (from top to bottom) in which statements of program are executed when they are two or more
    9) Conditional execution is when we want the program to execute a code not straight ,but from a branching road that we create( under certain conditions).
    10) the “ if keyword” create Conditional execution but also we can use the “else” keyword, together with if to create two separate, execution paths
1 Like
  1. What is an expression?
    A fragment of code that produces a value.

  2. What is a binding?
    A binding is a variable, and maybe likened to a tentacle, in that it grasps and holds values, rather than boxes, which contain values. Bindings may be defined by the keywords “let,” “var,” or “const.” “Var” was primarily used pre-2015, before “let” was introduced. “Const” is used to define constants.

  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, which is then applied in order to run to the wrapped program.

  5. Give an example of a function.
    The prompt() function in the browser environment is one example. The console.log() function is another.

  6. What is a side effect?
    A change in the internal state of the machine in such a way that it 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.
    The prompt() function produces the side effect of the dialog box. The console.log() function produces the side effect of printing text to the screen. The Math.max() function takes any amount of numeric arguments and gives back the value which is the greatest. When a function produces a value, it is said to “return” that value.

  8. 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. The order of execution is referred to at the “control flow.”

  9. What is conditional execution?
    Conditional execution is when the program only executes given instructions when certain conditions are met.

  10. What kind of keyword do you need to use to invoke conditional execution?
    In JavaScript, the “if” keyword is used to create a conditional execution.

2 Likes
  1. An expression is a combination of values, variables, and operators, which computes to a value.
  2. A Binding is ‘ties’ a value to a variable. It defines a variable.
  3. The collection of bindings and their values that exist at a given time.
  4. A function is a piece of code designed to perform a particular task. A function is executed when “something” invokes it (calls it).
  5. A function : prompt(“Enter something”);
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Side effect function :confirm Value: math.max
  8. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
  9. Not a single straight route but a branching route, where the program takes the proper branch based on the situation at hand.
  10. if, else if, and else
1 Like
  1. An expression is a fragment of code that produces a value
  2. A binding is a variable a letter or name that can be used to store a value or expression
  3. An environment is a collection of bindings and their corresponding values at a given point in time.
  4. A function is a value with a piece of program that is wrapped inside. This value can be applied in order to run the wrapped program
  5. Math.max() is an example of a function.
  6. A side effect is
  7. alert(“Hello World“) produces a side effect and Math.max(4,2) produces a value.
  8. Control flow is the order/sequence in which expressions, functions or instructions are executed/evaluated in a program.
  9. Conditional execution is when a program does not take a single route but may take a number of branching routes to arrive at it’s output, deciding which branch based on the situation at hand.
  10. In JavaScript we use if to invoke conditional execution
1 Like
  1. An expression is a code that produces a value.
  2. It is a function that remembers values.
  3. The sum of bindings is an environment.
  4. It is a program wrapped in a value.
  5. Console.log.
  6. Is the output of the functions that influence the word.
  7. alert(“hey”);
    a=5,b=8; c=a+b;
  8. It reads the statement in order.
  9. It creates a breanching road.
  10. If.
1 Like
  1. An expression is a fragment of code that produces a value.
  2. Binding is a way to retain or hold a value.
  3. An environment is a collection of values that exist at a given time
  4. A function is a block of reusable code that can perform an action, or a piece of program wrapped in a value
  5. Prompt holds the function that asks for user input
  6. A change in a way that effects the statements afterward is a side effect, like a popping up dialog.
  7. A function side effect would be like a dialog box or a message box, an interaction with the outside world. A function that produces a value would be something like 5*5 which would output the value 25.
  8. Control flow is the idea that code follows a certain pattern or structure, that being that code reads from top to bottom.
  9. A conditional execution is when a code branches off the top to bottom path to execute another piece of code.
  10. You can use an if statement to invoke a conditional execution
1 Like
  • What is an expression?
    Anything that produces a value. A fragment of code that produces a value e.g. 1; 1false;
  • What is a binding?
    Names used to catch and hold value e.g. address, name, number
  • What is an environment?
    A collection of bindings and their values that exist at a given time is an environment.
  • What is a function?
    A piece of program wrapped in a value.
  • Give an example of a function.
    prompt (“What is the number?”);
  • What is a side effect?
    Showing a dialog box or writing text to the screen is a side effect.
  • Give an example of a function that produces a side effect and another function that produces a value.
    Math.max produces a side effect and Math.max a value.
  • What is control flow?
    It is the execution of statements in a program in the sequency they are written.
  • What is conditional execution?
    It a diversion from the straight control flow of the program.
  • What kind of keyword do you need to use to invoke conditional execution?
    let, var and const
1 Like
  1. What is an expression?
    An expression is a fragment of code that produces a valut. Every value written litterally (45, academy etc
) is an expression.

  2. What is a binding?
    A binding is a special rule in a variable, including a keyword.

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

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

  5. Give an example of a function.
    console.log("")

  6. What is a side effect?
    Writting text to the screen is a side effect. ex: prompt("")

  7. Give an example of a function that produces a side effect and another function that produces a value.
    A function that produces a side effect would be for example the function alert(""). A function that produces value would be math.max("") or console.log("").

  8. What is control flow?
    The control flow is the action of executing the code from top to bottom.

  9. What is conditional execution?
    It is the action of giving different options, different paths.

  10. What kind of keyword do you need to use to invoke conditional execution?
    The keyword to us is “if”.

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

  2. What is a binding?
    A binding is a thing that allows you to catch and hold values, a variable.

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

  4. What is a function?
    A function is a piece of program wrapped in a value, and such values can be applied/executed to run the wrapped program.

  5. Give an example of a function.
    alert(Give me all your money!");

  6. What is a side effect?
    Showing a dialogue box or writing text to the screen is a side effect.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert(“b”)
    math.max(1,2,3);

  8. What is control flow?
    Is when your program contains multiple statements, the program will execute from top to bottom, like a story.

  9. What is conditional execution?
    Used when we want code to be executed only if a certain condition holds

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

1 Like