Binding, Functions and Control Flow - Reading Assignment

Lesson 14: Reading Assignment: Binding, Functions and Control Flow

Questions:

  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 reference to a value indicated by the word “let” or “var” at the beginning of an expression. The word “let” or “var” is always followed by the “name” of the binding and is given a “value” through the operator “=” and “an expression”.

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

  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 age”);

  6. What is a side effect?
    A side effect is 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.

    Prompt(“enter name”);

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

  8. What is control flow?

Control flow is the execution path in a program when the program contains more than one statement. Multiple statements in a program are always executed from top to bottom.

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

Conditional execution is created with the “if” word in JavaScript. It simply conditions the function to execute the code if, and only if, a certain condition (or conditions) is (are) met.

Keywords used for conditional execution are: “if” and “else”.

1 Like

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

What is a binding?
A binding is used to catch and hold values because a program can only access the values that it still has a reference to, using keywords like let, var (variable), or const (constant).

What is an environment?
The environment is the collection of bindings and their values. A program always starts with something in its environment already - bindings that are part of the language standard and bindings that provide ways to interact with the system, like a browser.

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

Give an example of a function.
Using the binding prompt holds a function that causes a dialog box to pop up asking for user input.

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.
The prompt function produces the side effect of a pop up dialog box. The function Math.max returns the value of taking any amount of number arguments and giving back the greatest.

What is control flow?
Control flow is the order in which multiple statements are executed.

What is conditional execution?
Conditional execution is when the program flows like a branching road, taking the proper branch based on the input given (if, then).

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

1 Like
  1. An expression is any string of code that returns a value, and also every value that is written out becomes an expression as well as expressions in parenthesis are also expressions built atop expressions to make larger complex expressions.

  2. A binding is the storing of a value to a label to be recalled at a later time for use.

  3. Environment is all of the given bindings and their associated values.

  4. A function is a piece of code that is wrapped in a value

  5. An example of a function would be Math.abs() to retrieve a numbers absolute value.

  6. A side effect is anytime a computations value affects the real world. Such as displaying an alert or showing text on the screen.

  7. A function that produces a side effect would be prompt() and a function that produces a value would be Math.max().

  8. Control flow is the order of execution of the steps in any given program from start to finish. It is generally top to bottom, left to right until conditional execution is used.

  9. Conditional execution is when values given determine the control flow of the program such as with binary, unary, and turnary operators

  10. You need the "if keyword to invoke conditional execution.

1 Like

1. What is an expression?

An expression is a fragment of a code that creates a value

2. What is a binding?

Bindings are holding values, the memory of the program

3. What is an environment?

An environment is a collection of bindings

4. What is a function?

A function is a program wrapped in a value

5. Give an example of a function.

Alert, prompt, math.max

6. What is a side effect?

Writing text on a screen or displaying a dialog.

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

“Alert” makes a pop-up screen and displays the text. Math.max returns the highest number out of a list.

8. What is control flow?

Its how the program executes one statement after another. From top to bottom.

9. What is conditional execution?

Its a code that will only be run if certain criteria are met

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

if (condition){then; else}

1 Like

1. What is an expression?
A piece of code that produces a value
2. What is a binding?
Binding o variable is used by JS to catch and hodl values.
3. What is an environment?
The collection of variables and their values that exist at a given time is called the enviroment
4. What is a function?
Piece of program wrapped in a value.
5. Give an example of a function.
function myFunction (p1,p2) {
return p1+p2 };
6. What is a side effect?
A function that can alter the external state of your application, this means that a function can alter parts or values of your application that don’t directly reside inside that same method
7. Give an example of a function that produces a side effect and another function that produces a value.
alert(“Hello World”); // produce a side effect, it displays a window in the browser
function myFunction (p1,p2) {
return p1+p2 }; // this function produces a value.
8. What is control flow?
The rules JS obey to read a program. From top to bottom.
9. What is conditional execution?
If a condition occurs, then it will execute something.
10. What kind of keyword do you need to use to invoke conditional execution?
Keyword if

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

  2. A binding is a tool in JavaScript that allows us to catch and hold values.

  3. A 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. The “alert” or the “console.log” function.

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

  7. The “alert” function produces a side effect; “Math.min” function produces a value.

  8. Control flow is the order in which the program executes the statements, from top to bottom.

  9. Conditional execution is when we create a situational branch in a program, executed only when certain conditions are met.

  10. The “if” keyword.

1 Like
  1. What is an expression?

An fragment of code which produces an value.

  1. What is a binding?

Catches and holds values in it.

  1. What is an environment?

Collections of bindings and values existing at an given time.

  1. What is a function?

Piece of program wrapped in a value

  1. Give an example of a function.

alert(“Hello World!”);

  1. What is a side effect?

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

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

prompt(“What’s your name?”);

  1. What is control flow?

It’s the codes execution order

  1. What is conditional execution?

The code is getting executed only when specific conditions are being met.

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

The keyword is if.

1 Like
  1. What is an expression?

A fragment of code that produces a value. Every value that is written literally is an expression (104 or “brother”). An expression between parenthesis is also an expression. A binary operator is applied to two expressions, a unary operator is applied to one expression.

  1. What is a binding?

It is a stored value in the memory of the computer. It is used to catch and hold values. Bindings are also called variables. There are three types of variables in Javascript: var, let and const. Nowadays let and const are more used than var, as it has some confusing properties. Let allows you to change the variable at a later stage. Const does not let the variable to change at a later stage. If we know that the variable is never going to change, using Const makes the code more robust. It is useful for bindings that give a name to a value so that you can easily refer to it later.

  1. What is an environment?

It is the collection of bindings and their values that exist at a given time. It is not empty when the program starts up. It always contains bindings that are part of the language standard, and most of the time, it also has bindings that provide ways to interact with the surrounding system.

  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. Executing a function is called invoking, calling, or applying it.

  1. Give an example of a function.

Console.log is a function that prints, for example. It is an expression that retrieves the log property from the value held by the console binding.

  1. 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. Functions may also produce values, in which case they don’t need to have a side effect to be useful.

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

Function that produces a side effect are, for example, prompt or alert. Most of functions do not produce a side effect, like console.log, math.max or math.min.

  1. What is control flow?

Is the way the program is executed. From left to right and, when there is more than one statement, from top to bottom.

  1. What is conditional execution?

When in the control flow there is more than one option, so depending on if a condition is met, a certain piece of code is executed. If a condition is not met, another certain piece of code is executed.

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

If, else if and else. With else you create a second alternative execution path. Else will execute if none of the previous execution paths have been triggered.

1 Like
  1. An expression is a fragment of a code that produces a value.
  2. A binding “grasps” values, like a reference.
  3. An environment is a collection of bindings and their values that exist at a given time.
  4. A function is a piece program wrapped in a value.
  5. An example e of a function is a pop up requesting for your passcode.
  6. A side effect is a dialog box or writing text on the screen.
  7. A function that produces a side effect is console.log(math.max) and a function that produces a value is (math.min)
  8. Execution order of statements in a program.
  9. A conditional execution creates a branching road, where the program takes a proper branch based on the situation at hand.
  10. “if” is the keyword used in javaScript to invoke a conditional execution.
1 Like
  1. What is an expression?

A piece of code that produces a value

  1. What is a binding?

A variable. var let or const

  1. What is an environment?

A collection of bindings and their values that exist at a given time which interact with the surrounding system.

  1. What is a function?

A piece of program wrapped in a value which can be applied to run a wrapped program.

  1. Give an example of a function.

console.log - writes out it’s arguments to a text output device.

  1. What is a side effect?

A piece of code that changes or affects the statements that come after it. Dialog boxes or writing text to a screen are side effects.

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

prompt("What is your name?); // example of side effect

var x = 2
console.log(x * 3)
returns 6 // example of function that produces a value

  1. What is control flow?
    Program that contains more than one statement executed like a story, top to bottom.

  2. What is conditional execution?
    Branching road based on the situation at hand.

  3. What kind of keyword do you need to use to invoke conditional execution?
    “if” - for sure and usually an “else” added for clarity.

1 Like
  1. Expression – A fragment of code that produces value. 22 or “psychoanalysis” are expressions. An expression between parenthesis is also an expression.
  2. A binding is when you hold a value to stay that value for an indefinite period of time or until told otherwise.
    Eg. let Bread = 3
    Let is the keyword that indicates that what follows it is a binding.
  3. Environment: A collection of bindings and their values at a given time. E.g. in a browser, even before any input has been put in, the environment will have functions already hard coded in the environment such as functions to nteract with the currently loaded website and to read mouse and keyboard inputs.
    4/5. A function is a piece of program wrapped in a value. E.g. in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.
    6/7.A side effect is anything that produces an outcome that interacts with the program you are using. e.g. showing a dialogue box or writing text on the screen.
  4. Control Flow is the order in which statements are executed, in the case of Java, top to bottom.
    9.When a program veers off the straight-line control flow based on the situation at hand. The Conditional execution is created with the keyword if, and only if, a certain condition holds
    10.if
1 Like
  1. What is an expression?

It is a fragment of code that produces a value.

  1. What is a binding?

Binding is when you take one or more pieces of code and combine the together ()

  1. What is an environment?

A collection of variables and their values that exist and a a given time.

  1. What is a function?

A function is a piece of code wrapped in a value. The values can be applied to perform certain task. The function is the task the code has in the program.

  1. Give an example of a function.
    console.log it prints whatever you code in the console. Another one is alert. it is used to create and alert block.

  2. What is a side effect?

Changes that is made to the internal state of the machine to affect the statement that comes right after it. Visible changes

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

console.log produce a side affect

prompt will take the input and produce a value.

  1. What is control flow?

It is the order in which the machine runs the code. from top to bottom.

  1. What is conditional execution?

Code is only executed if some or all of the conditions is true. It runs depending on the condition.

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

What is an expression?

An expression is a segment of code producing a value

What is a binding?

Key words such as “let”, var, or const which allow the holding of a value instead of it dissipating

What is an environment?

The collections 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 so they can be applied in order to run the wrapped program.

Give an example of a function.

Prompt(“enter passcode”);

What is a side effect?

Variables and other factors coded before which effect the outcome later on

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

Prompt(“Hello World”); (this is a side effect as it causes a prompt on the screen, thus a change in the “world”)

Console.log(5+5); (this creates a value of 10)

What is control flow?

A program with more than one statement that flows correctly.

What is conditional execution?

A branch in the code where the program chooses the direction based on input.

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

“if”

1 Like
  1. What is an expression?
    An expression is any piece of code that gives a value.

  2. What is a binding?
    A binding is a named label on a part of memory you use to contain information.

  3. What is an environment?
    An environment is the collection of bindings and their values that exist at any giving time.

  4. What is a function?
    A function is a named part of a program that does a specific task

  5. Give an example of a function.
    alert (“Hi, my name is Alice”)

  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.
    alert(“this is a function with a side effect”.)
    console.log(2+2);

  8. What is control flow?
    The order of executing code from top to bottom left to right.

  9. What is conditional execution?
    if - else statements
    If A is true, do this. If not, do that.

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

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

  • What is a binding?
    Binding is the same as a variable (var, let, const). To catch and hold values.

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

  • What is a function?
    A piece of a program wrapped in a value. i.e., preforms a specific operational task.

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

  • What is a side effect?
    A statement that results in an active change to the world. Affects the display, changes the result of an output, etc.

  • Give an example of a function that produces a side effect and another function that produces a value.
    alert(“side effect displays on the user interface”); let four = (5 - 1);

  • What is control flow?
    Top to Bottom program execution flow.

  • What is conditional execution?
    When a defined condition is met to execute a branch of the program.

  • 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 another word for a variable, which holds onto an entered value.

  3. What is an environment?
    The environment is the whole set of bindings and the values they hold in a given moment.

  4. What is a function?
    A function is a piece of program that is wrapped in a value and can be invoked or called to execute it.

  5. Give an example of a function.
    console.log is a function that writes out arguments to a text output device (like a browser’s console).

  6. What is a side effect?
    A side effect is a statement that can change something internally in the program or something in the world outside the program.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    The prompt function has the side effect of producing a dialog box. Math.max returns the largest number argument entered.

  8. What is control flow?
    Control flow is the order in which statements get executed in a program.

  9. What is conditional execution?
    Conditional execution uses if statements to make branching paths a code can do down based on conditions.

  10. What kind of keyword do you need to use to invoke conditional execution?
    The “if” keyword is used. The “else” keyword is also used, sometimes back to back.

1 Like

1.) An expression is a fragment of code which expresses a value. Every value that is written is an expression. Expressions can be written within expressions.
2.) A binding is essentially a variable. JavaScript uses it to catch and hold values. Bindings don’t contain values, they grasp them, because they can let go of one value and grab another. You can create a binding by using the keywords let, var, or const.
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. Values given to functions are called arguments.
5.) We have used the console.log function in order to print statements onto the console.
6 & 7.) Side effects are changes that happen as a result of functions, for example, a dialog box is a result, or side effect, of the alert function. When you assign a value to a variable, and enter the variable into the console.log function, it returns the value. This is also a side effect.
8.) The control flow is how the program reads the statements, starting from top to bottom.
9 & 10.) Conditional execution is when the program has multiple paths to choose from. This can be executed by implementing ‘if/else’ functions. For example, if the number is even, return true. However, if the number is not even (represented after ‘else’), return false.

1 Like

1.A fragment of code that produces a value is called an expression.
2.To catch and hold values, JavaScript provides a thing called a
binding, or variable:
3.The collection of bindings and their values that exist at a given time is called
the environment
4.A JavaScript function is a block of code designed to perform a particular task.
5.prompt(“Enter passcode”);
6. function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the main effect to the invoker of the operation.
7.prompt(“Enter passcode”);
console.log(Math.max(2, 4));
8.When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
9. Create a branching road, where the program takes the proper branch based on the situation at hand.
10. if

1 Like

1. What is an expression?
An expression is:

  • A fragment of code that produces a value
  • A value that is written literally
  • Expressions written between parentheses

2. What is a binding?
Binding, variable, or constant is a way to catch and hold values.

3. What is an environment?
An environment is a collection of bindings. When a program starts up, the environment is not empty.

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

5. Give an example of a function.
An example of a function is prompt which we have used to get user defined inputs in the previous sections. console.log is another function that we have used thus far.

6. What is a side effect?
A side effect is the product of functions that displays on the screen.

7. Give an example of a function that produces a side effect and another function that produces a value.
Function that produces a side effect: prompt
Function that produces a value: Math.max

8. What is control flow?
Control flow is the order of a program to be executed; top to bottom, left to right.

9. What is conditional execution?
Conditional execution is a way to execute functions in a program based on conditions.

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?
a. An expression contains a coding fragment which produces a certain value.

2. What is a binding?
a. In Javascript it is used to catch and hold values.

3. What is an environment?
a. It consists of the collection of binding and their values at a certain time.

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

5. Give an example of a function.
a. alert(“Welcome to my website”)

6. What is a side effect?
a. A side effect is 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 (“insert text”); function = console.log (Math.min(4, 8) +200);

8. What is control flow?
a. It is a straight-line direction in which fragment of code are executed

9. What is conditional execution?
a. It holds a certain condition before executing a code creating a branch on the control flow.

10. What kind of keyword do you need to use to invoke conditional execution?
a. There are multiple, for instance: “if” or “else”.

1 Like