Binding, Functions and Control Flow - Reading Assignment

What is an expression?

A fragment of code that produces a value is called an expression.
Expression is a piece of code that resolves to a value/becomes a value.

A statement is an instruction, an action. Expression is not an instruction or action, it’s only an expression, a value.

What is a binding?
The binding memorizes a number or a value.
That’s how the program keeps an internal state and remembers things.
To catch and hold values, we use bindings.

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?
A function is a block of code designed to perform a task.

Give an example of a function.
alert(“Hello!”);
console.log(firstname);

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.

prompt(“Enter password”); → side effect

console.log(Math.max(1, 3 ,5)); → value effect

What is control flow?
The order in which the program/computer executes statements in a script. The statements are executed from top to bottom, as if they are a fairy tale.

What is conditional execution?
Conditional executions are used to perform different actions based on different conditions.

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

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

  2. What is binding?
    Attaching value a to a variable

  3. What is an enviornment?
    Collection of bindings and these values that exist at a given time

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

  5. Give an example of a function?
    alert()

  6. What is a side effect?
    Showing a dialog 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? Side effect: console.log(Math.max(2, 4)); // pil 4 Function: console.log(Math.min(2, 4)+ 100);
    // pil 102

  8. What is control flow?
    Is the order function calls, instructions, and statments are executed or evaluated when a program is running
    .

  9. What is conditional execution? Conditional execution is created with the of keyword. Code to be executed if and only if a certain condition holds

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

1 Like

1. What is an expression?
It’s a fragment of code that provides a value
2. What is a binding?
It’s used to catch and hold values, binding = variable; let, var, and const, are also used to create binding (It’s like tentacles)
3. What is an environment?
It’s the collections of bindings and values that exist at a given time
4. What is a function?
It’s a piece of program wrapped in a value
5. Give an example of a function.
Prompt ( “Hi! enter a number”);
6. What is a side effect?
IT’s a change produced by previus changes made by statements
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 (2,4));
8. What is control flow?
It’s the way the program read the statements for the execution, it read them from top to bottom.
9. What is conditional execution?
It’s another way to control the execution of statements instead of a straigth line we can create “curves around it”, for this you can use per example the functions “if” or “else”
10. What kind of keyword do you need to use to invoke conditional execution?
if

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 allows you to catch and hold values in JavaScript by invoking a reference name linked to the memory address where it is stored. Bindings are preceded by keywords “let”, “var” or “const”.

  3. What is an environment?
    A collection of bindings or variables.

  4. What is a function?
    A function is a value that contains a program. Usually we envoke/call a function in order to run the program it holds.

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

  6. What is a side effect?
    Showing a dialog 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.
    Non-Side Effect: 1; Side Effect: let ten = 10; ten + 10;

  8. What is control flow?

The control flow is the order in which the program executes the functions in the script,usually from top to bottom as a story.
9. What is conditional execution?
The condition that you give to your program to execute the code and it has to meet he conditional rules.10.

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

1 Like
  1. Fragment of code that produces a value.
  2. This is sort of variable, but which can change value after operating with it.
  3. Collection of binding and their values that exist at given time.
  4. Piece of program wrapped in a value.
  5. Check biggest number: console.log(Math.max(3,7));
  6. Statement that leads to some changes in other statements, machine or anything else.
  7. side effect: prompt(“Hi!”);
    value: console.log(1+2);
    3
  8. Direction of execution of program. In Javascript it’s done from top to bottom.
  9. Statement will be only executed it it matches criteria.
  10. if
1 Like
  1. What is an expression?

An expression is a piece of code that resolves to a value.

  1. What is a binding?

A binding is what is created when two values become linked together.

  1. What is an environment?

An environment is the group of bindings along with their respective values in a program at a particular time.

  1. What is a function?

A function is a small segment of a program that is attached to a particular value and it is responsible for performing a specific task.

  1. Give an example of a function.

When invoked, the alert function brings up a notification with a message for the user.

  1. What is a side effect?

A side effect is a change that is usually initiated by a function.

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

The prompt function produces a dialogue box that pops up on the computer screen and this is a side effect. The Number Function is used to produce a number value.

  1. What is control flow?

The control flow is the “order” in which the statements in a program are executed.

  1. What is conditional execution?

Conditional execution is when there is more than one possible path for the control flow to follow. The path that the program will take depends on some condition, such as the type of value the program is given.

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

Conditional execution can be invoked by using the keyword if.

1 Like
  1. What is an expression?
    A piece of code that produces any value.

  2. What is a binding?
    A binding is any of the keywords that allow you to store data, this data can be changed.

  3. What is an environment?
    the total of bindings and their values that make up the ruleset.

  4. What is a function?
    a function is a small piece of code

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

  6. What is a side effect?
    When a nonpurefunction uses data outside of the function, such as a dialog box on a browser.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    a prompt box asking for a passcode, keeping track of how many tries.
    math.max etc.

  8. What is control flow?
    the order of execution of the code.

  9. What is conditional execution?
    An if or else choice that changes the outcome of execution

  10. 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. It another name for variables and it functions is to HOLD in memory a value. EXP: E = mc2, the letter E will be tight together with mc2 so when you use E in a function the computer will go in is memory to find mc2.
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. alert(“How are you today”).
6. Showing a dialog box or writing text to the screen.
7.

  • prompt(“How many donut do you want?”);
  • console.log(Math.max(2, 4));
  1. It is the manner in which the computer will read the program (from top to bottom) if it as more than one statement.
  2. In a usual control flow the computer run the program to top to bottom, in a conditional execution the program will have many “branch” were only a specific path we be take if the condition are complete.
  3. if, else, else if.
1 Like
  1. What is an expression? - A piece of code that results in a value.
  2. What is a binding? - It creates a link between variable and a value.
  3. What is an environment? - The collection of bindings and their values at any one time is called the environment.
  4. What is a function? - 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 is a side effect.
  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(2,4));
  8. What is control flow? - statements are executed top to bottom
  9. What is conditional execution? - where the program takes a branching road.
  10. What kind of keyword do you need to use to invoke conditional execution? - if, else and else if
1 Like
  1. a fragment of code that produces a value.

  2. The act of catching and holding a value. Blinding keeps a value in a internal state unless changed other wise by a different code.

  3. Collection of blinding and their values that exist in a given time.

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

  5. An example of a function is a message box prompting the user to enter a input like a password, number, name etc.

  6. A side affect is when a expression causes a change to the “world”. An example of the “world” is a expression that causes a change on a a screen by creating a pop up box.

  7. Side value:
    Prompt(enter your name)
    Pop up box appears.

    Value:
    console.log(Math.min(2,4))
    this math function gives the lowest value between 2 and 4

  8. Control flow is the matter in which code is a read and executed. Code is read from top to bottom usually.

  9. A conditional execution is a execution of a program when a certain conditions is meet or not execute if the condition is not meet.

  10. You must use the keyword if you a program to invoke a conditional execution. The if keyword will execute a action if a condition is meet or should be skipped if not meet.

1 Like

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

What is a binding? To catch and hold values

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

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

Give an example of a function. prompt(“Enter passcode”);

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

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

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

What is conditional execution? We want some code to be executed if, and only if, a certain condition holds.

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? When something (name or variable) is followed by a value
  3. ***What is an environment?***The collection of bindings and their values that exist at a given time is called
    the environment.
  4. ***What is a function?***A function is a piece of program wrapped in a value
  5. ***Give an example of a function.***f(y)=mean_value(a,b)
  6. What is a side effect? Showing a dialog 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.***console.log(Math.max(2, 4));
  8. ***What is control flow?***When your program contains more than one statement, the statements areexecuted as if they are a story, from top to bottom.
  9. ***What is conditional execution?***if the condition exist it produces a value otherwise it comes out
  10. What kind of keyword do you need to use to invoke conditional execution? if
1 Like
  1. What is an expression?
    A piece of code that produces a value
  2. What is a binding?
    Binding is also considered a variable that holds values for future use
  3. What is an environment?
    The collection of variables and their values that exist at a given moment.
  4. What is a function?
    A piece of program wrapped in a value
  5. Give an example of a function.
    The prompt variable has a function that requests an input from the user.
  6. What is a side effect?
    Changes in the internal state of the machine that affects the statements that come afterwards
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Math.max produces a value while alert() produces a side effect (a dialog box)
  8. What is control flow?
    The order in which javascript executes code; from top to bottom
  9. What is conditional execution?
    Having the program decide on which function to execute based on the situation
  10. What kind of keyword do you need to use to invoke conditional execution?
    if/else if/else
1 Like
  1. What is an expression?
    It is a fragment of code that produces a value.

  2. What is a binding?
    A kind of expression that defines a value. "It is a way to “catch and hold values.”

  3. What is an environment?
    It is a group of bindings and values.

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

  5. Give an example of a function.
    prompt and console.log are both functions.

  6. What is a side effect?
    When a dialogue box is shown or when text appears on screen.

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

let num = Number(prompt(“Pick a number”));

if (num < 10) {
console.log(“Small”);
} else if (num < 100) {
console.log(“Medium”);
} else {
console.log(“Large”);

  1. What is control flow?
    The order in which statements are executed in a program.

  2. What is conditional execution?
    This is when code uses the keyword “if” and the statements are executed based on certain conditions, and the execution takes a different path.

  3. 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 is called an expression. Every value
    that is written literally (such as 22 or “psychoanalysis”) is an expression. An
    expression between parentheses is also an expression, as is a binary operator
    applied to two expressions or a unary operator applied to one.

  2. What is a binding?
    Binding is provided by JavaScript to catch and hold values. After a binding has been defined, its name can be used as an expression. The value of such an expression is the value the binding currently holds.

  3. What is an environment?
    A collection of bindings and their values that exist at a given time in a program are known as an environment.

  4. What is a function?
    A function is a piece of program wrapped in a value that performs a specific task .i.e. a group of code that can be called by a program to compute a value.

  5. Give an example of a function.
    For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for
    user input. It is used like this:

prompt(“Enter passcode”);
and a dialogue box will appear

  1. What is a side effect?
    As per the example >prompt(“Enter password”) is known as a side effect as it show a dialog box to the screen. This can also be a value or text.

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

This is an example that produces a side effect as a dialog on the screen

alert(“Are you ready?”);
// → Are you ready?

This is a function that produces a return value

console.log(Math.max(6, 10));
// → 10

  1. What is control flow?
    Control flow is when a program contains more than one statement and the statements are executed as if they are a story from top to bottom; for example a first statement asks the user for a number and the number is divided so the second statement once executed shows the divided value of that number.

  2. What is conditional execution?
    Not all programs are straight roads. We may, for example, want to create
    a branching road, where the program takes the proper branch based on the
    situation at hand. This is called conditional execution. This is created with the if keyword in JavaScript.

  3. What kind of keyword do you need to use to invoke conditional execution?
    The keyword to invoke a conditional execution is if and else if

1 Like
  1. What is an expression?

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

  1. What is a binding?

a binding is the same thing as a variable, it is used to contain information.

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

  1. Give an example of a function.

a good example would be prompt() or alert()

  1. What is a side effect?

A side affect is a change to the internal state of the machine in a way that will affect the statements that come after it. A lot of functions are useful because of the side effects they produce.

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

Example of side effect: Prompt("Give me a number")
Example of a value: console.log(Math.max(2, 4));

  1. What is control flow?

The control flow is the order in which the statements are executed.

  1. What is conditional execution?

where a program takes the proper branch based on the situation at hand.

  1. 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. Anything that produces value is called an expression.
  2. Is representing a value we insert into variable.
  3. Collection of bindings and their values under its name is called environment.
  4. Function is piece of program wrappeed in a value.
  5. Prompt or alert are basic functions.
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Side effect: Prompt (“Please insert a number”)
    Value: console.log(Math.max(2, 4))
  8. Its the order in which the statements in the program are executed (from top to bottom).
  9. Conditional execution is branch based usage of certain statements.
  10. Conditional execution is created with the if keyword in JavaScript.
1 Like
  1. What is an expression? code that returns a value
  2. What is a binding? a way to associate values with an expression.
  3. What is an environment? The values that are currently active in all variables through bindings.
  4. What is a function? A part of a program.
  5. Give an example of a function. console.log(math.min(10,1));
  6. What is a side effect? when the function produces something beyond the value, (for example a box for the user to write something in).
  7. Give an example of a function that produces a side effect and another function that produces a value. alert(“Hi”); produces a dialog box with “Hi” in it, the dialog box is the side effect. math.max(25,40); is a function that returns a value (“40”)
  8. What is control flow? the direction that the program is run in (top to bottom).
  9. What is conditional execution? Parts of the code that only run is specific criteria are met.
  10. What kind of keyword do you need to use to invoke conditional execution? “if” or “else” are two examples of keywords that invoke conditional execution.
1 Like
  1. An expression is a fragment of code that
    produces a value, including: those that are
    written literally, those between
    parentheses, those that result from a
    binary operator applied to two
    expressions, or that result from a unary
    operator applied to one expression. An
    expression may also contain another
    expression (as a sentence may contain a
    subsentence).
  2. Another name for a binding in JavaScript
    is a variable, which is named storage for
    data. Any value may be placed in this
    storage, and it may be changed as often
    as needed.
  3. “The collection of bindings (variables) and
    their values that exist at a given time is
    called the environment.”
  4. A function is a block of defined, reusable
    code that is used to accomplish a specific
    task. It usually accepts input, processes it,
    and returns an output.
  5. An example of a function:

    console.log(3 * 2);

  6. A side effect is any effect other than
    the return value of a function.
  7. An example of a function with a side effect
    is: ‘>prompt(“Hello”);’ which produces a
    pop-up window. An example of a function
    that returns a value is: ‘>function Sum(x,
    y){return x+ y; };’ which will return the sum
    of x and y.
  8. Control flow is the order in which the
    statements of a program are executed.
  9. Conditional execution causes a program to
    perform different actions based on different
    conditions.
  10. Conditional execution is invoked by the
    keyword ‘if’ should the condition be true or
    ‘else’ should the condition be false.
1 Like
  1. What is an expression?
  2. What is a binding?
  3. What is an environment?
  4. What is a function?
  5. Give an example of a function.
  6. What is a side effect?
  7. Give an example of a function that produces a side effect and another function that produces a value.
  8. What is control flow?
  9. What is conditional execution?
  10. What kind of keyword do you need to use to invoke conditional execution?

A.1. An Expression is a fragment of code that produces a value. Expressions are often followed by a semicolon. Expressions are also known as statements. A list of statements defines a program.

A.2. A binding is used to catch and hold values. The equal (=) operator can be used to connect or disconnect bindings to new values. Moreover, after a binding is defined, its name can be used in an expression. Binding is synonymous with variable.

A.3. An environment is the collection of bindings and their values at a given time.

A.4. A function is a piece of program wraped in a value. Function takes an input and produces an output or value. Moreover, functions consist of keywords. These are words with a special meaning e.g. let, const, var, prompt, add, return, number, etc. These words should not be used as biding names.

A.5. Example of a function:

let ElizabethsAge = 94;
ElizabethsAge
94

A.6. Side effect is a change on the outcome of a function. Instead of a value on the output, it is something else other than a value, and this affects the statements that come thereafter. On the other hand, showing a dialog box or writing text to the screen is also a side effect.

A.7. Example of a function that produces an expected side effect:

console.log();
Example of functions that produce a value:
function add(a,b) {
const total = a+b;
return total;
}
add(2,8));
10

Math.random();

A.8. Control flow is a program containing more than one statement and the statements are executed in sequence, from top to bottom.

A.9. Conditional execution is a program that branches out by using the keyword “if” only if a certain condition holds.

A.10. Conditional execution is invoked by the keyword “if” or combining “if” with “else” to create two or more separate alternative execution paths.

1 Like