Binding, Functions and Control Flow - Reading Assignment

  1. An expression refers to a fragment of codes or the values produced by it.
  2. A binding catches and holds value.
  3. An environment is a collection of bindings and values that exist at a given time.
  4. It is a piece of program wrapped in a value.
  5. console.log(), prompt()
  6. The appearance of a dialog box/ writing text to the screen.
    7.a) prompt()
    b)console.log(), Number(), Boolean()
  7. Control flow suggests that statements are executed from a top to bottom manner.
  8. Conditional execution occurs only what a condition is being met(true), otherwise it is not executed/ other action is executed.
  9. if () and/or else ()
1 Like
  1. An expression is a fragment of code which produces a value.

  2. Binding is something which allows a program to catch and hold a value which has been produced, ready for later use.

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

  4. A function is one of the fundamental building blocks of JavaScript. It is a piece of program, a set of statements, that performs a task or calculates a value.

  5. An example of a function;

function square(number) {
return number*number;
}

  1. A side effect is a secondary effect or reaction that comes from an action we take. Side effects are any state change that can be seen outside of a function which occurs during a calculation of a result.

  2. Function producing a side effect;

function plusWithSideEffects(x, y) {alert (“This is a Side Effect”);
return x+y;}

Because it produces an alert dialogue.

Function which produces a value;

function plus (x, y)
{return x+y;}

  1. A control flow is the order in which expressions and statements, or blocks of code will run,

  2. A conditional execution is an execution of code which occurs only if a certain condition is met.

  3. The kind of keywords I would use to invoke a conditional execution are “if” and “else”.

1 Like

What is an expression?

An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value.

What is a binding?

Function binding . In JavaScript function binding occurs using the Bind () method. by this method, we can bind an object to a common function, so that the function gives different results when needed. Otherwise it gives the same result or gives an error while the code is executing.

What is an environment?

The JavaScript specification calls that a host environment . A host environment provides its own objects and functions in addition to the language core. Web browsers give it a means to control web pages. Node. js provides server-side features, and so on.

What is a function?

A function is a JavaScript procedure—a set of statements that performs a task or calculates a value. To use a function , you must define it somewhere in the scope from which you wish to call it.

Give an example of a function.

Function Expression:

A Function Expressions defines a named or anonymous function. An anonymous function is a function that has no name.

var fullName = function(firstName, lastName) {

return ${firstName} ${lastName};}fullName(“Jamal”, “Uddin”); // Jamal Uddin

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 (e.g., a global variable, or a variable in the parent function scope chain) Logging to the console.

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

printZeroPaddedWithLabel, is called for its side effect: it prints a line. The second version, zeroPad, is called for its return value.

What is control flow?

The control flow is the order in which the computer executes statements in a script. … A typical script in JavaScript or PHP (and the like) includes many control structures, including conditionals, loops and functions. Parts of a script may also be set to execute when events occur.

What is conditional execution?

The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed . The if/else statement is a part of JavaScript’s " Conditional " Statements , which are used to perform different actions based on different conditions.

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

The conditional statements in JavaScript are if, else, else if and switch-case statements. They are used for checking a specific condition and executing the code based on the specified condition .

1 Like
  1. A fragment of code that produces a value
  2. A binding, or variable, is used to “catch and hold values” in JavaScript.
  3. A collection of bindings and their values at a given time.
  4. A is a piece of program wrapped in a value.
  5. Function avg (a,b)
  6. The order in which the code is executed.
  7. Showing a dialog box with ‘alert’ is a side effect.
    Using Math.max or Math.min will produce a value
  8. The control flow is the order in which the computer executes statements in a scrpt.
  9. A statement which will bring the program in a specific next step
  10. If, else, or case
1 Like
  1. What is an expression?
    A code that produces a value is said to be an expression.

  2. What is a binding?
    A binding grabs and holds a given value. They are used to store values that can be used on a later stage.

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

  5. Give an example of a function.
    prompt(“Enter login details”)

  6. What is a side effect?
    A side effect is a wanted performance a function.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    -prompt(“Enter login details”) produces a side effect.

-console.log(33+33) gives a value

  1. What is control flow?
    Control flow is the execution of the programming code.

  2. What is conditional execution?
    Conditional execution is the execution of a programming code that gives different outputs that depend on the information entered by the user.

  3. What kind of keyword do you need to use to invoke conditional execution?
    if and else are commonly used to invoke conditional execution.

1 Like

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

A binding is a way to store a state or value.

An environment is the the collection of bindings and expressions.

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

function exampleOne {
    return 1 + 4;
}

A side effect shows a dialog box or can write text to the screen.

One function that produces a side effect is prompt("Enter your name"); will produce a dialog box to enter a name.
A function that produces a value could be console.log(Math.min(6,5)); and will return a value of 5

Control flow is the direction of operation that codes executes. From top to bottom, straight line control flow ------------->

Conditional execution is code that executes depending on the input and branches off accordingly.

The keyword to invoke conditional execution is of if and else

1 Like

1/. What is an expression.?

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

2/. What is a binding.?

 Imagine bindings as a tentacle,rather than boxes, they do not contain values they grasp them -two bindings can refer to the same value.

3/. What is an environment.?

  A collection of bindings & their values that exist at a given time is called an 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(“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 which produces a side effect and another function that produces a value.?

A function that produces a side effect…

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

And another function that produces a value…

console.log(Math.min(2, 4) + 100);
// → 102

8/. What is control flow.?

   Is a simple way we code, this way all our statements are evaluated..

9/. What is a conditional execution.?

  Part of the code is going to be executed only IF certain conditions are met.

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

  e.g;  if
1 Like

1: It is. fragment of code that produces a value.
2:it keeps the value for use in the program so you don’t have to retype the value every time
3 a collection of Bindings and their current values
4:a piece of program wrapped in a value
5:prompt( Enter your age); alert(" press enter again");
6: showing dialog box or entering text as required
7":prompt" produces a side effect. “math.min” produces a value
8:The order in which the program is executed . InjavaScript top to bottom like reading a story
9: It a execution dictated by a result. If “this: then” that" if result is less than 5 print 6 else print 25
10: If or else

1 Like
  1. An expression is fragments of code that return a value
  2. A binding (or variable) is when a value (a number or a string) is assigned to something. We use a keyword to create a binding. To create binding called name: let name = “John”
  3. An environment is a collection of bindings and their values that exist at a given time.
  4. & 5. A function is a piece of program wrapped in a value. It can be invoked to do a specific job, like: prompt(“Enter password”); OR alert(“Hello World!”);. The values (Eg: Enter password) given to a function are called arguments.
  5. A side effect is the result of a function. It could be a dialogue box like ‘Enter password’ or a value invoked by a function, such as (Math.max(2, 4));
    7, Side effect: prompt(“Enter password”);
    Value: (Math.min(2,4));
  6. Control Flow is the logical order in which statements are executed.
  7. Conditional execution is where there are two conditions or values and the program will fork accordingly. For example, if input is a number do a calculation, if it is not a number (NaN) ask the user to enter a number.
  8. if or else
1 Like
  1. What is an expression? An expression is any piece of code that evaluates to a value.
  2. What is a binding? Binding is assigning a variable to a value, and is how the program keeps an internal state.
  3. What is an environment? Is the bindings and values in the program at that moment.
  4. What is a function? A function is code that is wrapped in a value and performs a task when executed
  5. Give an example of a function. A function to add two variables would be: function myFunction(a, b) {return a + b; }
  6. What is a side effect? When a function has an observable effect outside its scope, other than returning a value. Such as logging data to a screen or modifying an external variable.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    The following function has a side effect, console.log(“Hi there!”);
    The following function has no side effect as it depends on only the local input variables: function add(a, b) {return a + b; }
  8. What is control flow? It is the order in which your code is executed.
  9. What is conditional execution? The next statement only executes if a certain condition is met.
  10. What kind of keyword do you need to use to invoke conditional execution? Use the if statement, such as if(x<10){console.log(“It is less than 10”)}.
1 Like

• What is an expression?
Every value is parts of an expression, and you can place them in between parentheses that also make other expressions upon other expressions. Book Answer: A fragment of code that produces a value is called an expression.

• What is binding?
Binding is producing new values from old values while keeping the old values. Two bindings can give reference to the same value. You cannot bind a value without giving it a value or it becomes ineffective. A binding name can be any word if it does not begin with a digit. A binding name can have special characters. You must use new values right away, or they will disappear. Book Answer: To catch and hold values, JavaScript provides a thing called a binding, or variable.

• What is an environment?
The environment is the capacity of data reserved within the program that looks empty but is not. There is a standard language within the space that provides ways to store bindings and other functions for interaction that connects with the mouse, keyboard, and browser. Book Answer: The collection of bindings and their values that exist at a given time is called the environment.

• What is a function?
A part of a program wrapped in a value. Book Answer: A lot of the values provided in the default environment have the type function. A function is a piece of program wrapped in a value.

• Give an example of a function?
Normally JavaScript booleans are primitive values created from literals that programmers use to compare or not compare.

Convert Fahrenheit to Celsius:
function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);}
toCelsius(77);


• What is a side effect?
A side effect is basically a return or the producing of value that has lots of useful functions displayed in a dialog box. Book Answer: 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.

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

Normally JavaScript booleans are primitive values created from literals that programmers use to compare or not compare. Book e.g.:

console.log(Math.max(2, 4)); // → 4
console.log(Math.min(2, 4) + 100); // → 102

• What is control flow?

Control flow is the way a computer executes the sequence of which statements that are executed in a common JavaScript scrip. Structures, loops, functions, and conditionals help tell when the execution of these events occur. Book Answer: When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. This example program has two statements. The first one asks the user for a number, and the second, which is executed after the first, shows the square of that number.

• What is conditional execution?

Based on different conditions, conditional executions help decide the flow. If it is a true conditional execution, an action will be performed. If the conditional execution is false, the condition will have to be changed to perform another action. Book Answer: 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. Conditional execution is created with the if keyword in JavaScript. In the simple case, 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?

Book Answer: With this modification, if you enter “parrot”, no output is shown. The if keyword executes or skips a statement depending on the value of a Boolean expression. The deciding expression is written after the keyword, between parentheses, followed by the statement to execute. The Number.isNaN function is a standard JavaScript function that returns true only if the argument it is given is NaN. The Number function happens to return NaN when you give it a string that doesn’t represent a valid number. Thus, the condition translates to “unless theNumber is not-a-number, do this”.

1 Like
  1. Any piece of code that produces a value.
  2. A statement that creates a binding with a value that is persistent.
  3. A collection of bindings and their values setting the current environment.
  4. A program that can be invoked to perform specific tasks.
  5. console.log (“Task to print”)
  6. Where a real world result appears or the statement changes an internal state.
  7. alert(textToShow);
    Boolean(10 > 9);
  8. The order of execution of the code
  9. Part of the process of having a complex set of statements is that some executions are not in sequence.
  10. if, else, switch & while, do and for.
1 Like
  1. What is an expression?
    Any piece of code that resolves a value.

  2. What is a binding?
    Biding stores a Value.

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

  4. What is a function?
    Is a piece of of program wrapped in a value.Can be applied in order to run the wrapped program.

  5. Give an example of a function.
    variable alert. alert (‘Buenos dias!’);

  6. What is a 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.
    A number, NaN…

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

  9. What is conditional execution?
    In straight-line order.if, else, else if.

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

1 Like
  1. Expression is a fragment of code that produces a value.
  2. Binding or variable holds values by grasping on them.
  3. Environment is a collection of bindings and their values that exist at a given time.
  4. A Function is a piece of program wrapped in a value.

function square(number) {
return number * number;
}
​
square(16);
OUTPUT
256

  1. A side effect is a term for changes that could display smth on the screen, or that could change the internal state of the machine.

  2. f->side effect: showing smth on the screen: prompt(“password”);
    f->value: console.log(Math.max(5, 12)); // -> 12

  3. Control Flow is a fundamental concept in programming that allows you to dictate how your code runs under different conditions or until a certain condition is met.

  4. Conditional execution means that the program takes a different branching road based on the situation. “if” . codes are executed only if ____…

  5. keywords: if, else, else if

1 Like
  1. A JS expression is a “sentence” of code. It is the basic line of JS that can define, output, or manipulate values and call functions. Each expression is usually separated via a semicolon

  2. A binding is an expression that grabs a value and holds it. Different bindings are how values are stored for calling or to be manipulated later.

  3. The environment is where all bindings and values are stored, including system defined keywords.

  4. A function is a set of rules that are applied to specified values. The values effected by the function are enclosed in parentheses.

  5. Math.max(2 , 6)

  6. A side effect is the resulting output by a function that is not a value. Functions not producing side effects will produce values.

7, The alert() function will produce a side effect, and the Math.min() function will produce a value.

  1. Control flow refers to how a functions are handled when more than one statement is provided. The functions will execute in order, top to bottom.

  2. Conditional execution is nonlinear control flow that allows for different functionality based on input.

  3. Conditional execution is called by the “if” keyword.

1 Like
  1. What is an expression?
    A fragment of code that produces a value.
  2. What is a binding?
    Code that catches and holds 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 program wrapped in a value.
  5. Give an example of a function.
    In a browser environment, the binding prompt holds a function that shows a dialog box asking for
    user input
  6. What is a side effect?
    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.
  8. What is control flow?
  9. What is conditional execution?
    Where the program takes the proper branch based on the situation at hand.
  10. 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. What is an expression?
    An expression is a code that takes values and uses operators to return a value.
  2. What is a binding?
    Binding stores the value for later use in the code. These are var or const. These stores can be changed.
  3. What is an environment?
    An environment is when there are values and bindings in the code at the same time.
  4. What is a function?
    A function is also a value that can output many statements. The values within a function(or values within a function value) are referred to as arguments.
  5. Give an example of a function.
    function A(B,C){
    return B + C;
    }
    A(B,C);
  6. What is a side effect?
    A side effect is a functions code that does not return a specific value. Examples are showing text in a prompt window.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert(“Side Effect”);
    Max.max(0 or Math.random()
  8. What is control flow?
    Control flow is the execution of code starting from the top to the bottom.
  9. What is conditional execution?
    Conditional execution is code that, if meeting certain requirements, will only execute.
  10. What kind of keyword do you need to use to invoke conditional execution?
    if, if else, else
1 Like
  1. What is an expression?
    A fragment of code that produces a value is called an expression and expression between parentheses is also an expression.
  2. What is a binding?
    Biding or variable we use to catch and hold values.
  3. What is an environment?
    The environment is collection of bindings and their values that exist at a given time.
  4. What is a function?
    A function is a piece of program wrapped in a value.
  5. Give an example of a function.
    Alert function.
  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.
    Alert function produces a side effect and foe example Math.max is function that produces a value.
  8. What is control flow?
    Control flow representing the statements who executes from top to bottom.
  9. What is conditional execution?
    When we want to create a branching road, where the program takes the proper branch based on the situation at hand we called that situation conditional execution.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If and else.
1 Like

Well explained. Thanks for the help :slight_smile:

  1. What is an expression?
    A fragment of code that produces a value
  2. What is a binding?
    A function to catch and hold values from previous outputs and/or memory
  3. What is an environment?
    Is the collection of bindings and their values that exist at a given time in a computing system
  4. What is a function?
    A function is a piece of a program wrapped in a value.
  5. Give an example of a function.?
    prompt is used to hold a function that shows a little dialog box asking for user input is used as an example in the book. Another used is console.log
  6. What is a side effect?
    Functions produce side effects if they modify states outsides its scope . They can be useful.
  7. Give an example of a function that produces a side effect and another function that produces a value
    prompt (“Enter passcode”); has the side effect of a prompting dialogue box. console.log(Math.max(2, 4)); produces no side effect, though produces a value.
  8. What is control flow?
    The direction of flow the computers execution of inputs in one single sequence.
  9. What is conditional execution?
    Is a useful fork in the road or branch for a program to be use in certain conditions.
  10. What kind of keyword do you need to use to invoke conditional execution?
    Both if and else and be used.
1 Like