Binding, Functions and Control Flow - Reading Assignment

  1. A fragment of code that produces a value
  2. like a tentacle, catch and hold values
  3. collection of bindings and their values that exist at a given time is called the environment
  4. A fx is a piece of program wrapped in a value
  5. in browser -> prompt -> dialog for user input
  6. Showing a dialog box or written text to the screen is a side effect. Not every fx has side effects.
  7. A) prompt(“Enter password”);
    -> user input
    B) console.log(Math.max(2, 4));
    //-> 4
  8. the order of execution of the statements
  9. based on condition (if else), there are options to execute
  10. If
1 Like

An expression is any fragment of code that produces a value. The code 22 and the code “Hello” are both expressions.
Statements in their simplest form are expressions followed by a semi colon.
.
A binding is used to catch and hold a value for future use. Bindings are given a name and that name is assigned a value. One way to create a binding is with the ”Let” keyword.

The collection of values that exist at a given time is called the environment.

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

An example of a function is Mathmax(2, 4)

A side effect is a change “in the world” produced by a statement - such as a displaying something on a screen or changing the internal state of the machine so in a way that will affect statements that follow.

Prompt (“Enter a passcode”); produces the side effect of causing a dialogue box with the words “Enter a passcode” appearing on the computer screen. Mathmax(2,4): is a function that produces the value 4.

Control flow is the method for selection of which statements comprising a program are executed and in what order. Absent any conditional or other branching execution instructions, statements are executed sequentially from top to bottom.

A conditional execution is an instruction that prevents automatic sequential execution of statements from top to bottom at some point in a program, creating (potentially) a branch around sequential execution. The conditional instruction is followed by a Boolean expression in parentheses. When that Boolean expression is true, a statement following the Boolean expression wrapped in braces { } is executed. If the Boolean Expression is false, the statement following the conditional instruction is skipped.

The conditional execution is initiated by the keyword “if”.

1 Like
  1. An expression is a piece of code that produces a value.
  2. A binding names a value or value’s and holds in it memory.
  3. An environment is a collection of bindings and their values.
  4. A function is a piece of program wrapped in a value.
  5. alert(“scammer trigger”)
  6. The answer to your function and/or value.
  7. console.log(math.min(8,4));
    // 4
    8.console.log(10 + 10);
    // 20
  8. A conditional execution starts with “if or else .”
    We write this in front of a code to execute if and only if a certain condition is me or else to create a separate alternative of an execution route.
  9. If or else.
2 Likes

• What is an expression?

A fragment of code that produces a value.

• What is a binding?

Bindings catch and hold values.

• What is an environment?

A collection of bindings and their values.

• What is a function?

A bit of program wrapped in a value.

• Give an example of a function.

As per EQ. THe “prompt” fucntion shows a dialogue pop-up when invoked.

• What is a side effect?

The result of invoking a function. A value returned after applying a function.

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

Using the “prompt” function will return a text box. Using Math.max will return a value.

• What is control flow?

The order in which instructions are executed.

• What is conditional execution?

Where control flow is dependent on a condition being satisfied and not just the order in which the instuctions are written.

• 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 or any value that is written literally such as “2” or “psychoanalysis”

  2. What is a binding?
    A binding is another name for a variable and it assigns a new value to another value, its like giving a value a name.

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

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

  5. Give an example of a function.
    console.log(Math.max(2,4,6));

  6. What is a side effect?
    A side effect is something that changes the internal structure of the machine in a way that 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.
    let theNumber = Number(prompt(“Pick a number”));
    if (!Number.isNaN(theNumber)) {
    console.log("Your number is the square root of " + theNumber * theNumber);

console.log(Math.max(2,4,6));

  1. What is control flow?
    Control flow is the order in which a computer executes statements in a script.

  2. What is conditional execution?
    Conditional execution controls whether or not the core will execute the instruction. It is a way to create a branching road where the program takes the correct branch of the road based on the situation at hand.

  3. What kind of keyword do you need to use to invoke conditional execution?
    Words used to invoke conditional execution are “if , else”

1 Like
  1. What is an expression?

An expression is a fragment of code that produces a value.

  1. What is a binding?

A binding is a variable that gets stored for future use. ‘let’ indicates the beginning of a binding, followed by the name of the binding, the ‘=‘ operator and an expression;

  1. What is an environment?

An environment is the collection of bindings and their values that exist at a given time.

  1. What is a function?

A function is a piece of program wrapped in a value - a value that can be applied in order to run the wrapped program, or function.

  1. Give an example of a function.

console.log(); or the book example gives the browser environment ‘prompt’ that looks like:
prompt (“Enter passcode”);

  1. What is a side effect?

A side effect is when a statement changes the internal state of the machine in such a way that will affect the statements that come after it.

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

alert ("Hi, my name is Louis!”); produces a side effect.
console.log(Math.max(6, 9)); produces a variable.

  1. What is control flow?

Control flow is the flow of statements within a program, usually left to right, top to bottom, like a story.

  1. What is conditional execution?

Created with the ‘if’ keyword, conditional execution uses branching roads, flows or paths to get a value if, and only if a condition holds.

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

‘If’.

1 Like

1 A fragment of code that produces a value.
2 Its a keyword used to hold a value.
3 A collection of bindings and their values.
4 Its a piece of program wrapped in a value. its used fo running programs.
5 An example is the function alert, wich displays a window that shows a message.
6 Showing a dialog box or writing text to the screen is a side effect.
7 Math.max, Math.min.
8 When a program is executed from top to bottom.
9 when we want some code to be excecuted IF certain condition is met.
10 If, else.

1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is also called variable and it is used to catch and hold values.
  3. An environment is 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. Example of a function: console.log(Math.min(10, 4)); or alert(“It is a function”);
  6. A side effect is showing a dialog box or writing text to the screen.
  7. A function that produces a side effect is console.log(Math.min(10,4); and function that produces a value is console.log(Math.max(11,6) - 5);
  8. A control flow is the order of executing statements, from top to bottom.
  9. A conditional execution helps to design workflows that can execute commands when specified conditions are met.
  10. Keyword: if
1 Like
  1. What is an expression?
    A piece of code producing a value
  2. What is a binding?
    Aka Variable, that which points/holds a value.
  3. What is an environment?
    The collection of variables and their values that exist at a given time.
  4. What is a function?
    Modules of code that complete a task.
  5. Give an example of a function.
    alert(“hello world!”);
  6. What is a side effect?
    The outcome of a function.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert vs math.max
  8. What is control flow?
    The order of execution, top-down in JS.
  9. What is conditional execution?
    predefined code parameters that determine if and when code is executed.
  10. What kind of keyword do you need to use to invoke conditional execution
    If, else
1 Like

What is an expression?

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

What is a binding?

Binding, or variable are things to hold values. Two bindings can give the same value.

Some keywords to create bindings: let, var, const,

What is an environment?

An environment is the collection of bidings 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 name”);

Console.log 10 + 30);

What is a side effect?

A side effect is 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.
alert (hello there);
console.log(2+2);

What is control flow?

When the program includes many statements, the statements are executed from top to bottom.

What is conditional execution?

Some programs are branching road, where the program takes the proper branch based on the situation at hand. This is called conditional execution.

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

Keyword to create conditional execution: if

1 Like
  1. What is an expression?
    A computer program statement that evaluates to some value. A Boolean expression would for example to either true or false.
  2. What is a binding?
    We can bind a object to a common function, so that the function gives a different result when needed. It allows us to easily set which object will be bound by the keyword when a function or method is invoked.
  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?
    It’s similar to a procedure, a set of statements that perform a task or calculates a value.
  5. Give an example of a function.
    Quite often we need to perform a similar action in many places of a script.
    For example when we would like to show a nice looking message when a visitor/user logs in, logs out and maybe somewhere else. Functions are the building blocks of the program. They allow the code called many times without repetition.
  6. What is a side effect?
    A change in the program’s state caused by an expression or a function call. Or a modification of a global variable in a procedure or function.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    A side effect could be:
  • Changing the value of a variable
  • Writing some data to disk
  • Enabling or disabling a button in the user interface
  1. What is control flow?
    When your program contains more then one statement. The statements are executed if they are a story from top to bottom.
  2. What is conditional execution?
    Not all programs are straight roads. It is created with the if keyword in JavaScript. If you want to take another road and want some code to be executed under certain conditions.
  3. What kind of keyword do you need to use to invoke conditional execution?
    The keyword “if”.
1 Like
  1. What is an expression?
  • A fragment of code that produces a value.
  1. What is a binding?
  • a keyword that provides a program the ability to catch and hold values.
  1. What is an environment?
  • a collection of bindings and their values 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.
  • a pop up box that requests the user to input a password.
  1. What is a side effect?
  • an action taken by the function provided in the program.
  1. Give an example of a function that produces a side effect and another function that produces a value.
  • printZeroPaddedWithLabel: a side effect of a function that will print a line of values.
  • zeroPad: returns a value within the program,
  1. What is control flow?
  • When statements get executed from top to bottom, almost like if someone reads a story from front to back.
  1. What is conditional execution?
  • When a program takes the proper branch of execution, based on the current situation.
  1. What kind of keyword do you need to use to invoke conditional execution?
  • if
1 Like

1. What is an expression?
Any sequence of values and operators that create a new value

2. What is a binding?
Binding or variable is used to catch and hold values. it can be defined with special words, let, var, const. After the bindings are defined the name can be used as expression.

3. What is an environment?
Collection of bindings and their values.

4. What is a function?
“Functions are the bread and butter of JavaScript programming.” - M. Haverbeke (Sorry, I couldn’t help myself :slight_smile: )

Function is made from variables and values, a piece of program wrapped in a value.

5. Give an example of a function.
console.log (square(2));
function square(n) {
return n * n
}

6.What is a side effect?
A side effect is where a function does something other that return a value such as writing to the screen or displaying a prompt or a dialog box.

7.Give an example of a function that produces a side effect and another function that produces a value.
Showing a dialog box - side effect
console.log( 3+5); - value

8. What is control flow?
The control flow is the order in which the computer executes statements.

9.What is conditional execution?
The code will be executed only the condition meets.

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 is an object that stores and holds values or expressions.

  3. What is an environment?
    An environment contains the standard language + all the bindings and values of the program.

  4. What is a function?
    A function is a piece of code that can take values as arguments.

  5. Give an example of a function.
    prompt(‘Enter your passcode’);
    The prompt function displays a form inviting the user to enter his passcode.

  6. What is a side effect?
    Side effect is a statement result that changes something that affects the program

  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log(‘Display data to the screen’);
    var myFunction = Math.max(4, 18);

  8. What is control flow?
    This is the direction of execution of code wiritten in Javascript, which is from top to down

  9. What is conditional execution?
    This is when the control flow have multiples branches.

  10. What kind of keyword do you need to use to invoke conditional execution?
    Special keywords “If” is used to choose those branches.

1 Like
  1. A expression is a set of values
  2. The collection of bindings and their values that exist at a given time, that is einviorment.
  3. A function is a pice of code wrapped in a value.
  4. prompt fx. It asks for a user’s input: prompt(“Enter passcode”);
  5. Showing a dialog box or writing a text to the screen is a side effect.
  6. Side effect: prompt(“Enter password”);
    Value: console.log(Math.min(1,3));
    number 1 will be the output.
  7. Control flow is the ability of the language to code, fx asking for a number and right after giving the number the square root of itself as uoutput. This is done in a certain row from top to bottom.
  8. It’s a ,branching road", each branch has a statement given, wich will be executed if that requirement will be true. The program selects the branch wich is true at a given time in other words.
  9. if and if else
1 Like
  1. An expression is any piece of code that produces a value. Literal values written out are expressions, as well as the results of applying an operator on values.
  2. A binding is a “tentacle”pointing at a value. Binding involves using a special keyword to initiate the binding, and giving it a name, a variable. Later you can refer to the variable to use it when you want.
  3. The environment is all the bindings and their values that exist at a given time.
  4. Functions are bindings that hold programs. Since they are bindings, that means they have variables. These variables refer to a program that have applied or invoked or called to return a result.
  5. alert(“Hello World”);
  6. Side effects are the results of a function that are displayed for the user to see such as a dialogue box showing some value or showing something in the console.
  7. Produces a value: Math.max(0,10). Produces a side effect: console.log(10).
  8. Control flow is the direction which a program runs. Normally, programs run like a straight line, where one line of code runs, then the next next line runs.
  9. Conditional execution is when control flow does not run in a straight line. It branches off to perform different things based on which conditions have met.
  10. The keyword if invokes a conditional execution.
1 Like

1.An expression is a sequence of values and operators.

2.Binding is what javascript does to hold values to other values

3.It is a collection of the values and their bindings

4.A function a pre determined wrapped value inside on another value. like a bag of information inside of another bag with its own qualities.

5.alert(“this course is great”)

  1. A side effect is when an expression changes something but not changing the value of the expression its wrapped it

  2. A function that produces a side effect is prompt(“enter your name”) this tells the program to open a side bar for a name input not changing the value its wrapped inside of.

    A function that produces a value is console.log (math.max(2,4); The . is telling the program to get a value of the max number in the string

8.the control flow is how the program reads the commands top to bottom and left to right

9.conditional execution is prompting the computer to execute commands only if certain conditions are met.

  1. If and else are keywords used to invoke conditional execution.
1 Like
  1. A fragment of a code that produces a value.
  2. To catch and hold values. let caught= 5*5; let indicates that this sentence is gonna define a binding.
  3. Collection of bindings and values that exist at a given time.
  4. A piece of program wrapped in a value.
  5. prompt(“enter passcode”); In a browser environment, a bind prompt holds a function that shows a little dialog box asking for user input.
  6. Showing a dialog box or writing text to screen.
  7. console.log, Math.max
  8. Is the order in which the computer executes statements in a script.
  9. To create a branching road, where the program takes the proper branch based on the situation at hand.
  10. if, else.
1 Like
  1. What is an expression?

A fragment of code that produces a value

  1. What is a binding?

A statement that catches and holds a value

  1. What is an environment?

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

  1. What is a function?

A piece of program warped in a value

  1. Give an example of a function.

let Age = Number(prompt(“Enter your Age”));

  1. What is a side effect?

When a function produces an effect in addition to returning a value

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

alert(“The alert function produces a dialog box in addition to returning the value”);
console.log(“The console.log function simply returns the value”)

  1. What is control flow?

The path the program executes according to the returned values

  1. What is conditional execution?

The path a program executes according to the value returned in an if statement.

  1. 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? 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 piece of code wrapped in a value.
5.Give an example of a function. The prompt function prompt(“What is your number?”);
6.What is a side effect? A statement that changes the internal state of the machine in a way that will affect the statements that come after it.
7. Give and example of a function that produces a side effect and another function that produces a value. console.log() Math.min
8.What is a control flow? The program reads from top to bottom.
9.What is a conditional function? A function that goes a particular path based on the user’s input.
10.What kind of keyword do you need to use to invoke conditional execution? If/Else

1 Like