Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?

Pieces of the overall puzzle, can contain several chunks of puzzle contained together. A collection of expressions becomes a statement. A list of statements a program.

A fragment of code that creates a value.

  1. What is a binding?

A binding allows the storage of a piece of information. For ecample let + name = whatever allows us to hold within the memory that name is equal to whatever. Defined bindings become expressions. The existing bindings are the environment.

Allows the machine to hold an internal state

  1. What is an environment?

There may be a set of functions already described within the environment. When these functions are attempted then this is the environment.

  1. What is a function?

A function is a set of instructions carried out to a set of variables

  1. Give an example of a function.

Function name (x, y){

Return (x * y) + y,

}

  1. What is a side effect?

A piece of coding that has some kind of impact.

A change to the internal state of the environment that impacts instructions that come after it.

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

Let n = 6 produces a side effect

Console.log(math.min(6, 2) + 200);

Not really sure, thought they both must have at the same time.

  1. What is control flow?

The order in which the code is executed.

  1. What is conditional execution?

If this then that. There are more than one route that can be taken.

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

If

  1. What is an expression?

An Expression is a a group of values that when put together make an executable phrase for the compiler to execute.

  1. What is a binding?

A binding for all intensive the same thing as a variable because variable’s are binding and can be thought of as tentacles that the user generates to be able to “hold” or “bind” certain values the user needs to a specific name.

  1. What is an environment?

The total collection of variables and the values associated with them is the called the environment.

  1. What is a function?

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

  1. Give an example of a function.

alert(“Good morning!”);

  1. What is a side effect?

A side effect is what happens when a function generates something for the end user to interact with such as alert invoking a dialog box.

  1. 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 is the alert function which produces a side effect in the form of a dialog box and one such function that produces a value is Math.max which will give you the larger value of two arguments.

  1. What is control flow?

The structure of the program the user is creating because programs are executed from top down.

  1. What is conditional execution?

Conditional execution is when a function will only act if certain parameters are met.

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

A keyword that looks for a value to meet certain criteria.

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

  2. Binding catches and holds value. let caught=2*8; let is telling us that caught is a binding. it is constant.

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

  4. A function is piece of program wrapped in a value. executing a function is called invoking , calling, applying. it performs a certain task.

  5. alert(“what up”);

  6. A side effect is a dialog box or writing text on a screen.

  7. side effect prompt(“Enter passcode”);

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

  1. Control flow is when a program has more then one statement they are executed from top to bottom.

  2. Conditional execution is when the program takes the proper path based on the situation at hand.

  3. Conditional execution keyword is if.

A fragment of code that produces a value

A variable that defines and holds values

The set of bindings that are defined

A piece of program wrapped in a value

Console.log

Any effect other than that return value

Prompt(“Enter Password”);
console.log(Math.Max(2,4));

Statements are executed from top to bottom

A branch in the Control flow

if

  1. What is an expression?

An expression is a piece of code that produces a value. It can be every written value, something between parenthesis, the binary operator applied to two expressions or even a unary operator applied to one.

  1. What is a binding?

A binding is a variable which is a store of information.

  1. What is an environment?

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.

  1. Give an example of a function.

prompt(“Hello guys”);

  1. What is a side effect?

They are statements that change the internal state of the machine, affecting 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.

  2. prompt(“this is a function with a side effect”);

  3. console.log(Math.max(3,50));

// → 50

  1. What is control flow?

Control flow is the order in which the statement will be taken into consideration by the program. Usually, from top to bottom.

  1. What is conditional execution?

It is a branching road where the program has to take the proper branch based on a given situation.

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

If and if/else too.

1)Expression is the fragment of a code that produces a value.Expressions can contain other expressions.
2)Binding or variable it;s a statement that helps the program to keep an internal state, catch, hold and reuse values.After a binding has define its name can be used as an expression in the value of the binding.
3)The collection of bindings and their values.
4)Function is a program wrapped in an value.The value of a function called argument.
5)function mycoolfunction(p1,p2){
return p1+p2p2;}
mycoolfunction(3,7)
6)Side Effect is the production of a function like a dialog box or text.
7) Value: function mycoolfunction(p1,p2) {
return p1+p2
p2;}
mycoolfunction(3,7)
Side effect: let age=Number(prompt(“What’s Your Age?”));
if(!Number.isNaN(Number) && Number>=18) {
console.log(“You May Enter”)}
else{ console.log(“Go Drink Your Milk”);}
8)Control Flow is the correct lines of each statement of the code from top to bottom for the correct execution of the programs.
9)Conditional execution is when we want a program to take an action based on certain conditions and it is created with the keyword if.
10)else if, else.

  1. Every value that’s written literally or a fragment of code is an expression eg +, 5 + 3, x = 9, string literals etc.

  2. Binding is a placeholder of a kind for a value in Javascript. Its also known as variables in other languages. We can declare a binding by using the " Let " keyword. We also can create binding by using " var " or " const " as well.

  3. In any program at a particular stage, the collections of all the bindings and their values is called the environment. The environment at program start-up is not empty because a program would have things like forms to fill, functions waiting to be called to execute etc

  4. A function is a program code to execute a task when called upon by passing arguments to the respective parameters of the function.

  5. (Math.max ( )) is an example of a function with the parameters in parenthesis. The ’ max’ is a function of the Maths object that returns the maximum value of the parameters. Consol.log () is also another function where it will log onto the console and " log " is a function of the Console object.

  6. Functions can either return a value or change the " state " of the computer. A side effect would be like changing the " state " by creating prompts or forms to prepare users to execute. An example of a side effect would be like a dialog box call.

  7. An example of a function that produces a value is ( Math.min (4, 5) ) // 4 is the answer.
    An example of a function that produces a side effect is Number(prompt(“Pick a number”));

  8. A program control flow reads the codes from top to bottom in JavaScript. That is why we cant use a binding or function even before its being created.

  9. A conditional execution is when we have option to choose. Conditional execution uses the IF keyword in JavaScript and executes if and only if a condition is met. Otherwise, another path is taken.

  10. Keywords for conditional executions include words like IF, Else IF, Else

  1. What is an expression?
    Every value that is written literally is an expression, a fragmant of code that produces a value.
  2. What is a binding?
    A variable that can define and hold a value.
  3. What is an environment?
    A group of bindings with their values.
  4. What is a function?
    A piece of program wrapped in a value.
  5. Give an example of a function.
    alert(“hello”);
  6. What is a side effect?
    An expression that can cause a change to the code.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    alert (“hello”);
    console.log (32%3);
  8. What is control flow?
    statements executed from top to bottom
  9. What is conditional execution?
    it will be executed only if a condition is true or false
  10. What kind of keyword do you need to use to invoke conditional execution?
    If and if/else
  1. What is an expression?
    A fragment of code that produces a value
  2. What is a binding?
    A variable
  3. What is an environment?
    All variables and their values at a given point in time
  4. What is a function?
    A piece of program returning a value
  5. Give an example of a function.
    console.log
  6. What is a side effect?
    Anything a function outputs besides returning values, like console outputs or dialog boxes
  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log(“text”) has the side effect of printing text in console; Math.max(4,2) returns just a value without side effects
  8. What is control flow?
    Controlling what different parts of the program run, depending on logic and environment
  9. What is conditional execution?
    When different parts of a program are executed based on specific conditions, like paths
  10. What kind of keyword do you need to use to invoke conditional execution?
    if/else
  1. An expression is a fragment of code that produces a value.
    a. x + y
  2. A binding is how JavaScript catches and holds values. ‘let’ indicates that the sentence is going to define a binding.
    a. Let c = x +y
    b. Let p = 10
    c. var s = 20 , var is JavaScript previous to 2015.
  3. An environment is a collection of bindings and values that exist at a given time.
  4. A function is a method that can accept inputs. It might perform a task, an operation and return an output. A function is a piece of program wrapped in a value. Executing a function is called invoking, calling, or applying.
  5. Function example
    Function myFunction(a,b){
    Let x = a +b;
    Return x;
    }
  6. Side effects are changes made by the program that changes what appears on the display or changes the program values.
  7. Side Effect: let a = “This is a test”; alert(a);
    Value: 2;
  8. Control flow is the order in which the program statements are executed. Depending on how the program is written, the statements can run sequentially or conditionally.
  9. In conditional execution, the program may or may not execute a statement or statements.
  10. Conditional execution is when the ‘if’ keyword is used.

1. What is an expression?

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

2. What is a binding?

To catch and hold values, JavaScript provides a thing called a binding, or variable.

You should imagine bindings as tentacles, rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value. A program can access only the values that it still has a reference to. When you need to remember something, you grow a tentacle to hold on to it or you reattach one of your existing tentacles to it.

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.

In a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.

6. What is a side effect?

When a statement changes the internal state 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.

The following function printZeroPaddedWithLabel prints a line (which is a side effect) :

function printZeroPaddedWithLabel(number, label) {

let numberString = String(number);

while (numberString.length < 3) {

numberString = “0” + numberString;

}

console.log(${numberString} ${label});

}

The following function zeroPad returns a value :

function zeroPad(number, width) {

let string = String(number);

while (string.length < width) {

string = “0” + string;

}

return string;

}

8. What is control flow?

Putting statements after one another gives you a program that is executed from top to bottom. You can introduce disturbances in the flow of control by using conditional (if, else, and switch) and looping (while, do, and for) statements.

9. What is conditional execution?

Not all programs are straight roads. We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand. This is called conditional execution.

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

if

A fragment of code that produces a value

Bindings are used to remember values and operations and asign it to a name

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

A function is a piece of program wrapped in a value

function add (a,b){
return a+b;}

Side affects are changes that occure when binded values are beeing used

console.log(a);
var a = “hi”;

The way the code is beeing read and executed

If you want the program to behave in a certain way if a certain situation occures, you need a condition.

if

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

  2. A binding equates a variable to a value.

  3. An environment is the current set of bindings.

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

  5. An example of a function is console.log.

  6. A side effect is a state change that is observable outside the called function other than its return value.

  7. An example of a side effect would be:
    var LuigiBalance = 105;
    LuigiBalance = LuigiBalance - 50;
    console.log(LuigiBalance);

  8. Control flow is a pictorial representation of the order in which computer code executes.

  9. Conditional execution is execution where the computer must make a decision about which step to execute next, based on certain conditions at the existing step.

  10. The keyword you need to invoke to use conditional execution is if().

Hello,

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

  2. A binding is an expression that binds a value to a term. It is made with the keyword let. Information is locked in a variable so that the computer does not forget it.

  3. The environment is the collection of bindings and values existing in a given moment. These bindings are both those set by the user, and present in the program that is run at startup.

  4. A function is a piece of program wrapped in a value, values can applied it order to run the program

  5. ex prompt : ("enter code ") , console.log , alert

  6. A side effect when a function produces a pop up box or writing on the screen is applied.

7.A alert(“who are you”). B. console.log = (Math.max(8+5))

  1. Control flow is a term that indicates how a program is run, usually from top to bottom.

  2. A conditional execution is a piece of program that runs only if a certain condition is met.

  3. conditional expressions, such as IF and possibly ELSE.

Best

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

  2. What is a binding?
    bindings are what computer programs use to catch and hold values, once a binding is defined its name can be used as an expression. when programs startup, they also have bindings that provide a way to interact with the system.

  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 a program that performs specific tasks given, put together by special values.

  5. Give an example of a function.
    alert(“Ivan was here”);

  6. What is a side effect?
    a side effect is a statement that stands alone but effects the program as a whole.

  7. Give an example of a function that produces a side effect and another function that
    produces a value.
    -prompt(“enter name here”)

  • function add(a, b) {
    console.log(a + b);
    }
    add(2,2)
  1. What is control flow?
    control flow is top to bottom execution.

  2. What is conditional execution?
    conditional execution is when code is only initiated if and only certain conditions apply.

  3. What kind of keyword do you need to use to invoke conditional execution?
    a keyword you need to use to invoke conditional execution is “if”.

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

  • What is a binding?
    attaching an object to a function using let

  • What is an environment?
    he collection of bindings and their values, there also exist preloaded bindings (for example to read mouse and keyboard input.)

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

  • Give an example of a function.
    prompt(“enter password”);

  • What is a side effect?
    showing something on the screen or writing text to the screen

  • Give an example of a function that produces a side effect and another function that produces a value.
    side effect: prompt(“enter passcode”)
    value: console.log (2*2)

  • What is control flow?
    the order in which statements are executed

  • What is conditional execution?
    depending on the value or the result the next execution is picked

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

1 Like
  1. A fragment of code that produces a value.
  2. A holder of value.
  3. 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. Such values can be applied
    in order to run the wrapped program.
  5. function name ( parameter1, parameter2, parameter3 ) {
    // code to be executed
    }
  6. An operation, function or expression is said to have a side effect if it modifies some state variable value outside its local environment.
  7. prompt(“Enter passcode”); (produces a side effect)
    console.log(Math.max(2, 4)); (produces a value)
  8. Control flow is the order in which the computer executes statements in a script.
  9. A branching road, where the program takes the proper branch based on the situation at hand.
  10. If, else if.
1 Like

What is an expression?
• An expression is a piece of code which produces (i.e. outputs) a value.
• Note: an expression can be made up of one or more other expressions (i.e. “nested” expressions)

What is a keyword or reserved word?
• A keyword is a word which holds a special meaning in JS and may not be used in the code for any purpose other than that which was given to it by the developers of the JS language.
• A reserved word is a word which also cannot be used in the JS code as it is reserved for use in future versions of JS.
• The full list of keywords and reserved words is given below:
o break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import interface in instanceof let new package private protected public return static super switch this throw true try typeof var void while with yield

What is a statement?
• One or more expressions, values, keywords, comments, and/or operators which when combined can act as instructions for the program or provide information about a piece of the program.
• Statements can be separated by adding a semicolon at the end of the statement.
• Statements are executed, one by one, in the same order as they are written.
• Multiple statements can be grouped together by being enclosed in curly brackets.

What is a binding?
• A “binding” is a type of expression which allows for assigning a value to a certain word (Note: the word used as the binding name cannot begin with a number, and can only contain letters, numbers, dollar signs, or underscores, but no other types of punctuation or characters).
• A binding is created using a statement starting with a special keyword (namely: let, var, or const), followed by the word which you would like to represent a given value, then the equal operator =, and finally the desired value which you would like to assign to the word, e.g.:
o let word = 10;
o Note: You can define multiple bindings within the same statement by separating the two individual binding expressions with a comma, e.g.:
let first = 1, second = 2;

What is an environment?
• An environment is the collection of bindings and their values which exist at a given time. This can include pre-loaded bindings that are part of the JS language standard, along with bindings defined by the developer of a given program.

What is a function?
• A function is a piece of a program wrapped in a value. The value can be applied (i.e. executed, invoked, or called) in order to run the wrapped program.
• The values between parentheses after the binding name are given to the program inside the function.
o Note: different functions require different numbers or type of arguments, depending on how the function was defined by the developer.

Example of a function
• An example of a function is found within the default binding “prompt”, which holds a function that shows a dialog box asking for user input, e.g.:
o prompt(“Enter passcode”)
• Another example of a built in default function is the console.log function, which outputs the values of the arguments (i.e. expressions) inputted into the function, e.g.:
o console.log(1+2)
//  3

What is a return value?
• A return value is the value produced or outputted by a function.

What is a side effect?
• A side effect is a type of return value which shows a dialog box or writes text on the screen.

Example of a function that produces a side effect
• prompt
• alert

Example of a function that produces a value
• Math.max(x, y)

What is control flow?
• Control flow is the order in which statements are executed by the program.

What is conditional execution?
• Conditional execution is when a program can flow along one of multiple possible paths, depending on which criteria are met.

What kind of keyword do you need to use to invoke conditional execution?
• The keyword “if” is used to invoke conditional execution.

1 Like
  1. What is an expression?
    An expression is any valid set of variables, operators, and expressions that evaluates to a single value.

  2. What is a binding?
    A binding is like a tentacle between a variable and a value. They don’t hold any information but they grasp them. Two bindings can point to the same value.

  3. What is an environment?
    The environment is the collection of bindings and their values existing in a given instance.

  4. What is a function?
    A function is an expression wrapped in a value, and it can be executed by calling it.

  5. Give an example of a function.
    alert(“Bitcoin to the Moon!”);

  6. What is a side effect?
    A side effect is any expression or function that displays or otherwise changes the string or value on the webpage, basically if the program changes visibly it is a side effect.

  7. Give an example of a function (a) that produces a side effect and another function (b) that produces a value.
    a) prompt(“Do you like your life?”);
    b) console.log(69+96);

  8. What is control flow?
    Control flow is the order in which a program will execute the code.

  9. What is conditional execution?
    Conditional Execution is a branch in the control flow’s execution, where JavaScript picks a branch depending if the conditions that are present.

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

1 Like

1.Fragment of code that produces value
2.To catch and hold values or variables
3.The collection of bindings and their values that exist at given time
4.Peace of program wrapt in a value
5. >console.log;
6.If something observable happens, it can display or change the state of the machine
7. >console.log(“my name”);
>var a=“20”;
8. A program contains many statements and it is the order of the code
9. When the program branches based on condition
10. IF, else

1 Like