Binding, Functions and Control Flow - Reading Assignment


#302
  1. Results in a value
  2. A binding lets you bind a value to a name and store it in memory
  3. A collection of values and bindings that exists at any given time
  4. A piece of program wrapped in a value
  5. for(var i = 0; i<11; i++) {}
  6. Showing a dialog box or writing text to the screen
  7. alert(“I’m a side effect!”)
    console.log(Math.max(2,4) + (Math.min(3,6)));
  8. Statements are executed in order, from top to bottom
  9. if function, when a program has more branches it can take depending on the situation
  10. if, else

#303
  1. Expression is any piece of code that produces a value
  2. Binding is like a tentacle that connects name to value
  3. Pre-existing bindings
  4. A piece of program with a name
  5. console.log(“hello”)
  6. Showing a dialog box or writing text to the screen
  7. prompt(“Enter password”)
    Math.min(2, 5)
  8. Order of executing statements (from top to bottom)
  9. It’s a way of changing the control flow depending on a logical condition
  10. if

#304
  1. A fragment of code that produces a value is called an expression. Every value
    that is written literally (such as 22 or “psychoanalysis”) is an expression. An
    expression between parentheses is also an expression, as is a binary operator
    applied to two expressions or a unary operator applied to one.
    2.To catch and hold values, JavaScript provides a thing called a
    binding, or variable.
  2. The collection of bindings and their values that exist at a given time is called
    the environment.
  3. A function is a piece of program wrapped in a value. Such values can be applied
    in order to run the wrapped program.
  4. Alert(“hello world”)
  5. Showing a dialog box or writing text to the screen is a side effect.
  6. alert(“hello”) vs. math.max(2,4)
  7. When your program contains more than one statement, the statements are
    executed as if they are a story, from top to bottom. This is control flow
  8. 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.
  9. Conditional execution is created with the if keyword in JavaScript

#305

[quote=“ivan, post:1, topic:3069”]

  • What is an expression?
    A piece of code that produces a value is called an expression.

  • What is a binding?
    The newly produced value is stored under a name. It binds the result of an expression to a name. This name can then be used as an expression.

  • What is an environment?
    The collection of bindings and their values at a given moment. This includes the standard bindings of the programming language and the bindings created by the programmer.

  • What is a function?
    A function is a block of code designed to perform a specific task. In combination with a function value you can execute the function (call it)…

  • Give an example of a function.
    function add(first, second){
    return first + second;
    }

  • What is a side effect?
    A side effect is something noticeable happening when you run the code, or something changing in the statements that follow.

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

function add(first, second){
alert( first + second);
}
add(3, 7)

function add(first, second){
return( first + second);
}
var sum = add(3, 7)

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

  • What is conditional execution?
    The code is only executed if a certain condition is met, for instance an IF statement.

  • What kind of keyword do you need to use to invoke conditional execution?
    If/else, loop, boolean expression.


#306

Continuing the discussion from Binding, Functions and Control Flow - Reading Assignment:

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

  2. What is a binding?
    Aka a variable. A piece of code that holds a value.

  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.
    prompt(“Enter passcode”);

  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.
    prompt(“Enter passcode”);
    console.log(Math.max(2, 5));

  8. What is control flow?
    The sequence in which your program executes statements, if there are more than one statements.

  9. What is conditional execution?
    When a program takes a different path in different circumstances.

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


#307

What is an expression?
Expression is peace of code that represents value.
In this statement: var = 22
expression is value of 22.

What is a binding?
Connection to catch and hold the value.
var x = 10;
console.log(x * x);

What is an environment?
Collections of variabiles at a given time (browser powered background code).

What is a function?
Fundamental building block of code designed for particular task.

Give an example of a function.
function name() {}
alert(“Good morning!”); or
prompt(“subscibe”, “email”);

What is a side effect?
Function result that affect other statements down the code.

Give an example of a function that produces a side effect and another function that produces a value.
alert(“Good morning!”); side effect
var y = 10;
console.log(y * y); // 100 value

What is control flow?
Execution order of JS statements from top to bottom of the code

What is conditional execution?
Statement with an option between boolean routes (true or false).
if When true, execute. When false, go down do else if.
else if When true, execute. When false, go down do else if or else.
else When true, execute.

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


#308
  1. An expression is a fragment code that produces a value. Any value that is written literally is an expression.
  2. Binding is when a program stores values internally so that they can be used later.
  3. An environment is a collection of bindings and their values within a program.
  4. A function is a program wrapped in a value.
  5. Ex. The binding ‘prompt’ holds a function that makes a dialog box appear that asks for user input.
  6. A side effect is an observable change in the state of an application.
  7. Ex. alert(“this is a side effect”)
    Ex. console.log(1+1); This produces a value.
  8. It is the order in which individual statements, instructions or function calls in a program are executed.
  9. A statement created with the keywords ‘if’ or ‘else’ that controls the flow of execution of statements depending on the condition that is following the keywords ‘if’ or ''else.
  10. You need conditional expressions such as the keywords ‘if’’ or ‘else’.

#309

What is an expression?
And piece of code that results in a value. An operator with 2vslues resulting in a 3rd value is an expression

What is a binding?
This is used to store a value for use in other expressions and statements

What is an environment?
This is the status of all binding that exist in the computer at any given moment.

What is a function?
A function is a set expression that can be invoked at anytime like a binder.

Give an example of a function.
The example in the book goes like this
prompt(“enter passcode”);
The binder ‘prompt’ invokes a function that will render a dialoge box on the computer prompting the user to enter a passcode.
Any expression can be stored within a function. In a simple way it is a shortcut so you do not have to replicate code to perform common operations within a program.

What is a side effect?
When the computer dies something as a result of a function or expression it is called a side effect. Showing a dialogue box with the prompt function is a side effect.

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

prompt(“enter passcode”);
will produce a dialogue box which is a side effect

let a = 2+2;
will produce the binding a=4

let a = (prompt(“enter passcode”));
This will open a dialgue box and ask the user to enter a value that will then be bound to the variable ‘a’

What is control flow?
This is the effect where by the computer will exectute expressions, and functions and statements in the order in which they are writtin in the program.
Thus there must be some logic to the order of operations and this is controlled by the order in which the expressions, and functions and statements appear in the program.

What is conditional execution?
This is where the control flow can be different when different conditions are present.
when a=1 then path 1 in the program is taken, if a=2 then path 2 is taken.

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


#310

1. What is an expression?

A fragment of code that produces a value. Every value that is written literally (such as 22 or “psychoanalysis”) is an expression. An expression between parentheses is also an expression, as is a binary operator applied to two expressions or a unary operator applied to one. The simplest kind of statement is an expression with a semicolon after it.

2. What is a binding?

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

let caught = 5 * 5;

Commands ‘let’, ‘const’ and ‘var’ can be used to create a binding.

Binding names can be any word but the name must not start with a digit. A binding name may include dollar signs ($) or underscores (_) but no other punctuation or special characters. Special words which cannot be used for binding names, are:

break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import interface in instance of let new package private protected public return static super switch this throw true try typeof var void while with yield

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. Such values can be applied in order to run the wrapped program. Values given to functions are called arguments.

5. Give an example of a function.

For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input. It is used like this:

prompt(“Enter passcode”);

6. What is a side effect?

An output of a function in a form of 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) a function producing a side effect:

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

b) a function producing a value:

function countApples(JansApples, Bensapples){

return JansApples + Bensapples

}

8. What is control flow?

When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.

Control flow refers to changes value types down the line so that the output of one function fits the required input type to the next function.

9. What is conditional execution?

Conditional execution is a branching road, where the program takes the proper branch based on the situation at hand. Conditional execution is created with the ‘if’ and ‘if/else’ keywords in JavaScript.

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

while, if, if-else


#311
  1. What is an expression?
    its a fragmented code that produces a value

  2. What is a binding?
    its a way to catch and hold values.

  3. What is an environment?
    the collection of bindings and their value at the given time.

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

  5. Give an example of a function.
    a prompt shows a little dial box

  6. What is a side effect?
    An expression that affects the statement that comes after it side effect.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    side effect: channel12 function: console.log(Math.max(2, 4));

  8. What is control flow?
    when statements are executed from top to bottom

  9. What is conditional execution?
    when the program takes a branched road depending on the situation. not top to bottom.

  10. What kind of keyword do you need to use to invoke conditional execution?
    we would use the if statement.


#312
  1. An expression is a fragment of code that produces a value, e.g. a value written, an expression between parentheses, a binary operator applied to two expressions etc. It’s like fragment of a sentence in human language.

  2. A binding is when you tag a value to hold on to, e.g. tagging an expression to a new value, so when you call it out later it will give you that value.

  3. A collection of bindings and their values at any given time.

  4. A function is a program that is wrapped in value which is a collection of bindings to perform a task. When you ‘call’ a function, you usually directly use the name of the bindings that holds the function.

  5. Example: console.log

  6. A side effect is when a statement in the programming is changing the world (e.g. display something on the screen), or changes the internal state of the machine in the way that it will affect statements that come after it.

  7. Function that produces a side effect - e.g. prompt (shows a dialog box asking user input);
    Function that produces a value - e.g. Math.max (returns a value that is the greatest); Number (converts a value to a number).

  8. Control flow is the order how the program is executed when there is more than one statement. It goes from top to bottom just like how human reads a story.

  9. Conditional execution - executing a program is like going down a path while meeting requirements of different conditions along it. Sometimes when the path branches out into more than one paths, it chooses its path depending on the deciding expression written after the keyword e.g. “if”, which sets out the conditions to execute.

  10. if, else, else if, switch.


#313
  1. A fragment of code that produces a value is called an expression.
  2. A binding or variable is used to catch and hold values.
  3. A collection of bindings and values that exist at a given time is called an environment.
  4. A function is a piece of program wrapped in a value.
  5. A binding prompt holding a function that shows a box asking for an input.
  6. Showing a dialog box or writing text to the screen is known as a side effect.
  7. side effect function; console.log(Math.max(2, 4));
    // → 4
    value function; console.log(Math.min(2, 4) + 100);
    // → 102
  8. The way that a program, containing more than one statement is executed.
  9. Conditional execution- creating a branch road, where the program takes picks the correct branch, based on the situation at hand
  10. keyword "if"

#314
  1. A fragment of code that produces a value
  2. It holds a value that can be used later.
  3. A collection of bindings in a given time frame.
  4. A piece of program wrapped in a value thats pre-loaded in the default environment.
  5. console.log
  6. An Application state change that is observable outside the called function other than its return value.
  7. console.log text output is a side effect. Math.max calculates the largest number which is a value.
  8. The order in which statements are processed (top to bottom).
  9. When a program branches out and takes different paths based on ‘if’.
  10. ‘If’

#315
  1. A code that represent some value, it can simple typed value or within the parenthesis with operators which return some value is called the expression.
  2. JavaScript defines the keywords or values which helps for defining the new values or storing values and having particular meaning called the binding.
  3. At the time of program starting all the Binding and their values available to use called the environment. The environment also provide the facility to interact with the surrounding system.
  4. A piece of program that wrapped into values called the function.
  5. prompt(“Enter passcode”) prompt function shows dialog box asking for the user input.
  6. Showing Dialog Box or writing sentence on the screen is called the side effect
  7. prompt(“Enter passcode”) prompt function shows dialog box means produces side effect and Math.max(2,4) function produces value
  8. Program contain more than one statement. The way of executing the statements one after the another is called the control flow
  9. During the execution of the program the part of program get executed according to the situation is called the conditional execution.
  10. if keyword used for conditional execution. The part of code executed when the particular condition is satisfied.

#316
  1. What is an expression?

A fragment of code that produces a value

  1. What is a binding?

Binding stores value so you can use it later. Variables can catch and hold values, and therefore are also a binding.

  1. What is an environment?

A collection of variables and their values that exist at a given time is called environment.

  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.

  1. Give an example of a function.

An alert function

  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.

math.max function produces a side effect. console.log will produce a value

  1. What is control flow?

When your program contains more than one statement, the statements are executed from top to bottom.

  1. What is conditional execution?

When you can choose between two different routes based on a boolean value. It is written with an if statement.

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

if statement


#317
  1. The expression will returns a value

  2. Binding is when you point a variable to another value

  3. Environment is a collection of bindings and their values at the time of the programs existence.

  4. A function is a group of code that can be called by the program to compute a value

  5. Its a global function example… used to evaluate if a value is an illegal number

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

  7. Control flow is the way the program is executed. Javascript control flow is top to bottom like humans read a page.

  8. Conditional execution is like a fork in the road. The program uses if, else, if else to evaluate a condition and continue executing the branch of code based on the value returned from that condition.

  9. if, else, else if


#318

1, An expression is a piece of code that resolves to a value e.g var sum = a + b;
2, A binding or variable stores things that can called and used later.
3, An environment is the local variables.
4, Functions is something that accepts arguments then executes code then sometimes returns an output. It is used to abstract away commonly used tasks.
5, function sum(a,b) {
return a + b;
}
6, When an expression for function modifies something outside it’s own scope.
8, Control flow is the order of code execution.
9, Where conditions can be set to select different control flows.
10, Conditional execution can be invoked with if, if else, switch.


#319
  1. What is an expression?
    An expression is any combination of values and operators that make another value.

  2. What is a binding?
    A binding can hold the “memory” of an object, value or expression and define it for later use.

  3. What is an environment?
    An environment is where expression(s) can be stored or resolved.

  4. What is a function?
    A function reveals a value for a very specific purpose that can be called multiple times.

  5. Give an example of a function.

function HODL(BTC) {
if (BTC == “Satoshi”) {
return true;
} else if (BTC == “CIA”) {
return false;
}
}

  1. What is a side effect?
    Changes the state of the computer or the general output of the program creates some state change in the world thereafter

  2. Give an example of a function that produces a side effect and another function that produces a value.
    A) alert(“hello world!”)
    B) console.log()

  3. What is control flow?
    Program containing more than one statement, they are then executed in one story, from top to bottom.

  4. What is conditional execution?
    The branch path a program takes based on the situation and value returned from an expression

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


#320
  1. A fragment of code that produces a value is an expression.
  2. Binding catches and holds values.
  3. Environment is the collection of bindings and there value that exist at a given time.
  4. Function piece of program wrapped in values.
  5. Prompt (" Enter password");
  6. Side Effect showing a dialogue box or writing text to the screen.
  7. Side effect ex.
    Prompt (" Enter your Password")
    Value ex.
    Console.log ( Math.max(2,4));
  8. Control flow order in which we code and have our statements evaluated.
  9. We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand.
  10. If and else

#321
  1. What is an expression?
    An expression can be multiple things:
    A fragment from the code that creates the value.
    A literal value.
    An expression between parenthese.
    A binary operator between 2 expressions.
    An unary operator to 1 expression.

  2. What is a binding?
    A binding a tool to grab en hold values.

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

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

  5. Give an example of a function.
    console.log and prompt

  6. What is a side effect?
    A side effect is a result of a function. It is a value that is returned. However it is possible to have both a side effect and a value as a result.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Prompt(“Give a number”)
    Console.log(2+2)

  8. What is control flow?
    Control flow is the way the code follows after each other.

  9. What is conditional execution?
    Conditional execution happens when a branch is taken based on the given code.

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