Binding, Functions and Control Flow - Reading Assignment

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

  2. What is a binding?
    A binding is caching a value by linking a name/word to a value or a string, thereby be able to remember values or any other data of interest.

  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.
    prompt is an inbuild function. There is default functions and you could build your own function with wanted code. Functions takes in arguments, but the type and how many arguments depends on the function. These arguments are values given to the function to compute the code within the function.

  6. What is a side effect?
    A side effect is when a statement given would affect the outcome of other statements coming later in the code, thereby effecting more than just its own statement.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    A function that write out to the screen is a function that has the side effect of typing to the screen and many of these functions are used because of there side effects.

    Functions could also return values, thus being useful without additional side effects.

  8. What is control flow?
    Control flow is in which way the statements are executed. Normally the statements are executed from top to bottom, as a story.

  9. What is conditional execution?
    A conditional execution is code that would be executed only if a certain condition holds. Like if a>b, do this! {code;}

  10. What kind of keyword do you need to use to invoke conditional execution?
    else If statements! So, the keywords used for conditional execution are if, else if and else. In addition to if-else statements you could also use while, do-while and for loops, which also would be invoked if the conditional holds true, but these has the property of being continuously being invoked until it turns false.

What is an expression?
A fragment code that produces a value.
What is a binding?
Is a variable used in JavaScript to catch and hold value.
What is an environment?
The collection of bindings and their values that exists at any given time.
What is a function?
A piece of program wrapped in value. This value can be applied in order to run the wrapped program.
Give an example of a function.
Password entry field
What is a side effect?
Side effect are when one of the reasons functions are useful. Such as showing dialog box or text to the monitor.
Give an example of a function that produces a side effect and another function that produces a value.
(i) Side effect - prompt(ā€œEnter passcodeā€)
(ii) Value - Math.max(2,4);
What is control flow?
Is the order in which computer executes statements in a program
What is conditional execution?
Where a program contains branches depend on the situation at hand. If and only if certain conditions are met will that branch of the program run.
What kind of keyword do you need to use to invoke conditional execution?
If or else

What is an expression?
A piece of code that has a value

What is a binding?
A statement that is used to catch and hold values.

What is an environment?
A collection of bindings and their values.

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

Give an example of a function.
prompt(ā€œEnter passcodeā€);

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

Give an example of a function that produces a side effect and another function that produces a value.
console.log(Math.max(2, 4));
// ā†’ 4

console.log(Math.min(2, 4) + 100);
// ā†’ 102

What is control flow?
The order in which statements are evaluated.

What is conditional execution?
Some of the code will be executed only if a certain condition is fulfilled or true.

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

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

  2. What is a binding?
    A binding is used to catch and hold values. Bindings (variables in 2nd edition) are tentacles; they grasp values. Bindings are what allow the program to access the values.

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

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

  5. Give an example of a function.
    Console.log()

  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.
    A function that produces a side effect: The prompt function produces a dialog box.
    The Math.max function produces a value:
    console.log(Math.max(2,4));
    // 4

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

  9. What is conditional execution?
    The program can go two different routes based on a Boolean value (possibly resulting from input by a user).

  10. What kind of keyword do you need to use to invoke conditional execution?
    The keyword if is used to invoke conditional execution. Also, possibly if/else pairs.

  1. An expression is a piece of code in a statement.
  2. Binding is used to link certain values with variables - itā€™s essentially a way to store values in order to do something with them later.
  3. An environment is a list of all bindings existing in the same time.
  4. A funtion is a piece of program wrapped in a value.
  5. function add(a, b) {return a+b;}
  6. A side effect is the effect that the function has on the world.
  7. console.log (ā€˜blockchains are coolā€™); function add(a, b) {return a+b;}
  8. Control flow controls the order in which the statements are to be executed. Itā€™s top down.
  9. Conditional execution is when some statements are executed only if a condition is met.
  10. if
  1. An expression is a piece of code that returns a value.

  2. A binding is a value or string set to a variable like a pointer.

  3. An environment is all bindings and related values together at some point in time.

  4. A function is a collection of code steps that is performed when the function name is executed.

  5. Function: add(a, b) { return a + b; }

  6. A side effect is a change in the state of an application; i. e. modifying external parameters, logging to the screen, writing to a file, etc.

  7. alert(ā€œHello Ivanā€); console.log(99+4);

  8. Sequence of steps executed, when you have more than 1 statement.

  9. The associated code is only executed, when the condition is met.

  10. If is a key word to invoke conditional execution.

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

What is a binding?

catching and holding values

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

What is a function? 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. prompt(ā€œenter passcodeā€); console.log(Math.max(4,5,6));
What is control flow? when your program contains more than one statement, the statements are executed as they are a story, from top to bottom
What is conditional execution? it is created with if keyword in JavaScript, conditional execution happens where the program takes the proper branch based on the situation at hand
What kind of keyword do you need to use to invoke conditional execution? if, if else, else

  1. An expression refers to a section of code the resolves in a value.
  2. Binding or variables are provided by JavaScript to keep the internal state of the programme. It keeps pieces of data under a name which is useful for tracking the state of a programe.
  3. The environment is the collection of bindings and their corresponding values at any given time. This includes bindings that are part of the language standard and surrounding system.
  4. A function is a set of statements that perform a task or caluclate a value. It is defined one time but can be called any number of times.
  5. alert("Hi Everyone") is an example of a function
  6. A side effect is any interaction with the outside world from within a function. It includes the act of writing text or showing a dialog box to the screen.
  7. A function that produces a side effect is console.log and a function that produces a value is Math.min e.g. Math.min(5,6,7).
  8. Control flow is the order in which a program executes statements.
  9. Conditional execution refers to a set of commands that execute if a specified condition is true. So it creates a branch to the control flow of the program.
  10. The keyword to invoke conditional execution is of type if. This includes (if, else, and switch) and looping (while, do, and for)
  1. 4 + 5 is an expression for example that gives us a value.

  2. It is a way to grab a value to a name and bind the value with it.

  3. It is the collection of both binding and their values that exist at a given time.

  4. A piece of program wrapped in a value that can be applied to run the wrapped program.

  5. Example for getting the sum of two values by a function:
    function totalSum (val1, val2) {
    return val1 + val2;
    }

    totalSum (24, 55); // gives us 79

  6. Showing a dialogbox or writing text to the screen is a sideeffect of a function for an example.

  7. prompt(ā€œEnter your nameā€); // produces a sideeffect
    Math.min(500, 235); // produces the value 235

  8. The way the program is executed. Like when reading a story, from top to bottom.

  9. A conditional execution is a execution that executes if a certain condition holds.

  10. For an example:
    var rightNumber = 6;
    let userGuess = Number(prompt(ā€œGuess the right numberā€);

    if (userGuess === rightNumber) { // THIS IS WHERE YOU INVOKE THE CONDITIONAL EXECUTION
    console.log(ā€œYou guessed the right number!ā€);
    }

    else {
    console.log(ā€œYou guessed wrong!ā€);
    }

  1. What is an expression?

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

  1. What is a binding?

producing a new value without changing an old value is called binding or variable

  1. What is an environment?

The collection of bindings and their values that exists at a given time is called the environment.

  1. What is a function?

Function is a piece of program wrapped in a value.

  1. Give an example of a function.

alert(""); prompt(ā€™"); console.log ("");

  1. What is a side effect?

change that effects the state of the machine that will effect the statement that come after it.

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

console.log produces value, showing the dialog box or writing text is a side effect

  1. What is control flow?

Control flow is simular to story flow from top to bottom

  1. What is conditional execution?

When we want code to execute if and only if the conditions are met

  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. ANYTHING THAT PRODUCES A VALUE IS AN EXPRESSION.

2. BINDING KEEPS AN INTERNAL STATE THAT REMEMBER THINGS, CATCH AND HOLD.

3. THE COLLECTION OF BINDINGS AND THEIR VALUES THAT EXIST AT A GIVEN TIME.

4. A PIECE OF PROGRAM WRAPPED IN A VALUE SUCH VALUES CAN BE APPLIED IN ORDER TO RUN WRAPPED PROGRAMS.

5. CONSOLE.LOG("") IS A FUNCTION WHICH WHICH OUTPUTS INFO.

6. SIDE EFFECT = SHOWING A DIALOG BOX OR WRITTING TEXT TO THE SCREEN.

8. CONTROL FLOW= IS THE ORDER IN WHICH EXECUTES STATEMENTS IN A SCRIPT.

7.SIDE EFFECT= CONSOLE.LOG PRODUCES A SIDE EFFECT AND MATH.MAX PRODUCES A VALUE.

9 CONDITIONAL EXECUTION= IS A FUNCTION THAT ALLOWS THE PROGRAM TO EXECUTE SOME CODE OR SOME PARTS OF THE CODE IF THE STATEMENT PROVIDED AGREES WITH THE CONDITION OR FULFILL THE CONDITION REQUIRED.

10. CONDITIONAL EXPRESSIONS =IF:smile:

What is an expression?
Values with operators make up expressions.

What is a binding?
A binding is a variable.

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 piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.

Give an example of a function.
A function can bring up a dialog box prompting a user for a password.

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.
A function that uses alert () will display a dialog box, thus producing a side effect. Math.max is a function that produces a value.

What is control flow?
Statements in a program which are executed sequentially are straight line control flow because one statement is executed after another from top to bottom. Thus
a control flow is simply the order in which statements in a program is executed.

What is conditional execution?
A conditional execution executes a statement if a condition is met.

What kind of keyword do you need to use to invoke conditional execution?
The ā€œifā€ keyword.

  1. An expression is a series of JS code that produces a value.

  2. A binding, also known as a variable, is a tool JS uses to assign and hold values for later use.

  3. The environment in JS by default is made up of a series of bindings. These can be modified or added to, which changes the environment that portion of code operates under.

  4. A function is a piece of code that performs some number of operations to return a value.

  5. A function can be as simple as adding a group of numbers together and getting a sum.
    function findsum(a,b){
    return a+b;
    }

  6. A side effect is when a function makes a visible impact on the screen i.e. showing an alert message or printing some string or value to the screen. The most common is the console.log function.

  7. console.log(ā€œHello, world!ā€); is an example of a side effect that produces a string.
    console.log(3+5); would return a value of 8 to the screen.

  8. Control flow is the order that JS executes commands - from top to bottom.

  9. Conditional execution comes into play when there are conditional statements that can prevent some parts of the code from executing. This replaces the straight line control flow that is normally executed.

  10. the keywords IF and ELSE indicate branches that conditional execution can take, and are followed by the portion of code that should be executed.

An expression is a line of code that produces a value

A binding or variable allows you to store a value for future use

The environment is all the bindings (and their values) that exist at a point in time.

A function is a named piece of code that exists in your environment that you can call to do stuff. For example, console.log() prints text out to the console.

A side effect is something that changes the environment in a way that could affect subsequent lines of code and/or interacts with the outside world. For example, using console.log will append text to the console, which will affect where the next console.log call starts writing text. Changing the value of a variable may cause side effects as well. However, calling a function like Math.abs() will return a value instead of causing side effects.

Control flow is the order in which statements are executed.

Conditional execution is when a program could take one of multiple paths based on some condition that exists at the time. For example:

if(i==3){
    console.log("Hello");
} else {
     console.log("World");
}
  1. What is an expression?
    Any code that creates a value is referred to as an expression.

  2. What is a binding?
    In Javascript binding or variable, is used to catch or hold values. Bindings do not contain values they grasp them like tentacles.

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

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

  5. Give an example of a function.
    function myFunction(p1, p2) {
    return p1 * p2;

  6. What is a side effect?
    Displaying a dialogue box or some text on a monitor

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

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

  9. What is conditional execution?
    Conditional execution is basically a programme that executes base of pre-defined conditions, most programmes take a straight road, branching the road allows programmes to take the appropriates direction based of situational circumstances.

  10. What kind of keyword do you need to use to invoke conditional execution?
    The keyword IF is used.

1 Like

1 Expression Piece of code that prodces a value

2 Binding It catches or holds values produced by functions - for later use. Can then be used as an ā€˜expressionā€™ itself.
let, var, const are keywords used that show we are doing a binding.

3 Environment The bindings and the values produced that are present at a given time.

4 Function Is a value which contains a wrapped program

5 Example (3*5);

6 Side effect A consequece of running that function; that produces an effect on the screen -

maybe text or a popup. If the function only producesa value its not called a side effect

7 Example console.log alert or prompt
console.log (Math.min 5,7)

8 Control flow The order that the statement are executed. They are executed top to bottom - often straight line

9 Conditional When alternative routes areavailable with different conditions being met

10 Keyword If

  1. a fragment of code that evaluates to a value
  2. a binding is just a variable that is given a value in an assignment
  3. the full set of all bindings
  4. a piece of self contained code producing a value
  5. Function SpecialAdd (a,b) { return (a+b) }
  6. aside from the main functionality of a function, doing something additional is a side-affect., eg screen display.
    7.SideFunction(a,b) { console.log (a+b); return (a+b) } ā€¦andā€¦NoSideFunction(a,b) { return (a+b) }
    8.the way the statements are executed
  7. where the statements have some conditions attached to them that determine what statements will be executed.
  8. IF

1. What is an expression?

Expression is a fragment of code that produces a value. It can be a literal value, an operator applied to a value or values, or a complex sequence of computations whose end result is a value. All of these are expressions.

2. What is a binding?

Binding is the same as variable. It is used to record and keep (bind) values to be re-used later.

3. What is an environment?

The environment is the collection of all the existing bindings and the values they point to, at any given point in time.

4. What is a function?

Function is a piece of program held by a special binding with the type function. Function can be invoked by, for example, using the name of the binding thatā€™s holding it.

5. Give an example of a function.

prompt("Name?") ā€“ this function will create a dialog window with the word Name? in it and a text field below it. It will then wait for the userā€™s input.

6. What is a side effect?

Side effect is something that a function does, aside from producing a value kept by that functionā€™s binding.

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

The example of the function prompt("Name?") that I provided in my answer to Question 5 above has a side effect of having a dialog box with some text in it appear on the screen.

Function Math.max(1, 100) will produce a value 100 without having any side effects.

  1. What is control flow?

Itā€™s the order in which the programā€™s multiple statements are executed, usually from top to bottom.

9. What is conditional execution?

Itā€™s when the program can choose one of the branches to execute, depending on certain conditions.

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

if

What is an expression?
-a part of code that produce a value.Every value that is wraten is an expression .Expression can contain other expressions .

What is a binding?
In JS to keep ,hold,catch a value is useful a binding or variabule.Binfing should be deffine and can be used as an expression

What is an environment?
Collection of existing bindings with values.There function can be to interact with loaded web page

What is a function?
Function is a pice af program wriped in a value.Can call a function by using parentheses an expression wich produce a function value .Usualy directly name of the bindings are holding the function .

Give an example of a function.
console.log(Math.min(5,10));

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

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ā€));
console.log("Your number is the square root of " +
theNumber * theNumber);

What is control flow?
Some code to be executed if,only if,a certain condition holds .\

What is conditional execution
using some logic to stop or execute part of code

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

What is an expression?
A fragment of code that produces an expression.

What is a binding?
A keyword to hold or catch values.

What is an environment?
A collection of bindings and values.

What is a function?
A function is a subprogramme wrapped in a value.

Give an example of a function.
Alert(ā€œsmackā€);

What is a side effect?
A side effect is any application state change that is observable outside the called function other than its return value. Side effects include: Modifying any external variable or object property.

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

prompt(ā€œEnter passcodeā€);

Math.max(2,4);

What is control flow?
Stops JS from executing code exclusively from top to bottom by telling it where to go or what to ignore if conditions are not met.
What is conditional execution?
Like logic statements, conditional execution runs a code when logic is found to be true or false.
What kind of keyword do you need to use to invoke conditional execution?
If or else or else if