Binding, Functions and Control Flow - Reading Assignment

What is an expression?
An expression (or more expressions) are part of a statement each giving a result/value.
What is a binding?
A binding or variable, defined by a name, is a link to a value that is given to that binding at a certain time and can change if we assign another value to it inside a program. We can also have a constant wich points to a certain value and keeps that value a long as it lives
What is an environment?
An environment contains all the bindings/values that exist at a certain point in time
What is a function?
A function can have an input (argument), does something with it (the statements inside the function) and gives you back an output. The function is defined by a function name. After defining it we can call it by that name and give some argument(s).
Give an example of a function.
here is an example of a function to concatenate 2 arguments (or add them up if the args are numeric): function concatenate (arg1, arg2) {return arg1 + arg2}
What is a side effect?
A side effect is when a expression inside a function talks to the outside world (outside that function) for example changing a variable outside the function
Give an example of a function that produces a side effect and another function that produces a value.
without side effect:
function concatenate (arg1, arg2) {return String(arg1) + String(arg2)}

with side effect:
var arg1 = “Hello”, arg2=“World”;
function concatenate (arg1, arg2) {return String(arg1) + String(arg2)}

What is control flow?
the top to bottom execution of the statements that exist inside your program. It can be sequential (straight) or conditional
What is conditional execution?
Based on a condition that is true or false the program chooses a different path wich means different statements will be executed depending on the result of that condition.
What kind of keyword do you need to use to invoke conditional execution?
keywords are: If … then … else …

1 Like

What is an expression?
It is a pice of code that produces a value.
For instance:
1+2
“true”+" love"
(1<2)&& (3==8)

What is a binding?
is a link between a space in the memory of the computer and a handler. The space in the memory holds a value and the handler is the name. For instance in

let cat= “cute”

the name is cat and the value is the string “cute”

What is an environment?
It is the collection of bindings and values in a program.

What is a function?
A function is a program that operates on a prescribed set of values
(its arguments)

Give an example of a function
Number()
Number.isNaN
Math.pow

What is a side effect?
Are the results (like the display of an output or a change
in the internal memory) produced by a statement and that
affect the code coming afterward.

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

An example that produces side effect:

prompt(“Pick a number”)

An example that produces values :
Math.pow(2,2)

What is a control flow?
Is the order in which different statements appear in a program.

What is conditional execution?
Is a condition that has to be meet in order to execute a program.

What kind of keyword do you need to use to invoke conditional execution?
A conditional execution is implemented with the “if” statement.

1 Like
  1. A fragment of code that produces a value.
  2. Bindings are variables that can be named and stored.
  3. The collection of bindings and their values that exist at a given time
  4. A piece of program wrapped in a value
  5. prompt(“Enter passcode”);
  6. Showing a dialog box or writing text to the screen when executing a program code.
  7. Side effect: alert(“Hello, world!”);
    Value: counter++;
  8. The “flow direction” of executing a program, depending on conditional executions.
  9. Certain conditions to change the control flow if needed. (the program takes the proper branch based on the
    situation at hand)
  10. If, switch, for, while…
1 Like
  1. An expression is a part of code, which creates a value.
  2. A binding (variable) is a value, which is stored in JS and can be named
  3. An environment is a scope of bindings, which exist at a given time.
  4. A function is a value with ability to perform an action
  5. An example of a function is prompt(“any value”). It shows a dialog box asking for input.
  6. A side effect is a changing which affects following statements, so can change the world in some way.
  7. !false; - produces only a value - true
    alert(“some value”); - produces a window
  8. A control flow is a way of program execution.
  9. A conditional execution is a way of execution, which considers a condition of situation.
  10. if, else
1 Like
  1. An expression is a piece of code that creates an output value. For example, !false;
  2. Binding is a way for JS to catch and store values, also known as variables.
  3. An environment is the state of the bindings and values at a given time of the code.
  4. A function is a piece of code represented in a value.
  5. An example of a function in the binding prompt which has a function of asking users for input.
  6. A side effect is an outcome of a function or statement that changes the state of another statement.
  7. // side effect
    prompt("Enter Number: ");
    // value
    console.log(Math.max(3,5));
    
  8. Control flow is the way your program behaves given its conditions and statements
  9. Conditional execution is controlling the flow of your program based on prerequisites to be met.
  10. To invoke conditional executions, you must invoke keywords like if, else if, and else.
1 Like

–An expression is a fragment of code that produces a value. Expressions are used as components of JavaScript statements.
–A binding, or variable, is an item that is used to store/point to a value. Commons words used to create bindings are LET, VAR, & CONST. CONST indicates that the identifier won’t be reassigned. LET is a signal that the variable may be reassigned and that it will only be used in the block it is defined. VAR is considered the weakest signal as it may or may not be reassigned & may or may not be used for an entire function.
–The environment is a collection of bindings & their values that exist at a given time.
–A function is a piece of program wrapped in a value. These values can be applied in order to run the wrapped program. Executing a function is referred to as: invoking, calling, or applying the function.
–Ex. function ivanIsPretty(handsome, stunning) {
return handsome + stunning;
}
– A side effect is a state change to an application that is observable outside the called function; other than the functions return value.
–Side Effect Function
alert(“Cherry Blossom”);

–Value Function
function addNumbers(1, 2) {
return 1 + 2;
}

–Control flow is the order in which a computer executes statements in a script.
–Conditional execution is created with the word “if” in order to execute code only under specific conditions. Conditional execution may be used when a programmer wants to create branches in the code.

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

  2. What is a binging?
    a variable. This allows you to define something to be able to be used later.

  3. what is an environment?
    collection of variables that compile to be called an environment.

  4. What is a function?
    a type of structure to solve the problem you assign within it.

  5. Give an example of a function.
    function addNumbers (myNumber, yourNumber) {
    return (myNumber + yourNumber);

}

6.What is a side effect?
the outcome from a function (return).

7.Give an example of a function that produces a side effect and another function that produces a value.
side effect:
function subtractNumbers (a,b) {
return (a - b);

}

value:
console.log (4*6);

8.What is control flow?
the order that code is executed. top to bottom.

9.What is conditional execution?
when a conditional statement is provided that measures different outputs according to the information processed.

  1. What kind of keyword do you need to use to invoke conditional execution?
    if and else.
1 Like
  1. What is an expression? A fragment of code that produces a value

  2. What is a binding? It is used to catch and hold values. After a binding has been defined, its name can be used as an expression.

  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 a program wrapped in a value. Function calls can be used within larger expressions.

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

  6. What is a side effect? An expressing that changes the internal state of the machine in a way the it will affect the statements that come after it. Showing dialog box or writting text to a screen is a side effect.

  7. Give an example of a function that produces a side effect and another function that produces a value. Side Effect function prompt(“Enter passcode”); Value function console.log(Math.max(2, 4))

  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.

  9. What is conditional execution? Used to create a branching road, 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? “if” keyword

1 Like
  1. A fragment of code that produces a value
  2. Also called a variable, that which holds values
  3. The collection of bindings and variables that exist at a given time.
  4. A reusable fragment of programmatic logic which accepts one or more values and returns a value.
  5. const square = function(x) {
    return x * x;
    };
  6. Altering state that exists outside of the function.
  7. // Side effect:
    var x = 1;
    function (x) {
    x = 2;
    }
    // returns a value
    function (x, y) {
    return x + y;
    }
  8. Path of execution that a program takes.
  9. Optional paths or control flows based on program state.
  10. if, else, while for, break, switch-case-default
1 Like

1.) What is an expression?

Answer: A fragment of code that produces a value.

2.) What is a binding?

Answer: Is the way that JavaScript defines value referenced as a variable. These values can be changed at any time.

3.) What is an environment?

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

4.) What is a function?

Answer: A piece of a program that is wrapped in a value.

5.) Give an example of a function.

Answer: prompt(“Enter Email”);

6.) What is a side effect?

Answer: The subsequent changes that take place to other commands from an expression after it is entered to the computer.

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

Answer: alert(“Click OK”); - Brings up a dialog box
console.log(1 + 1); - Produces the value of 2

8.) What is control flow?

Answer: The order in which the code or statements are written to be executed.

9.) What is conditional execution?

Answer: Created with the “if” keyword, it is the conditional way a program executes based on the conditions at hand.

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

Answer: Keyword "if"

1 Like

What is an expression? Code which includes literals, variables, operators, and expressions that produces a single value.

What is a binding? A binding or a variable is assignment of internal state used to catch and hold values.

What is an environment? An environment is the collection of bindings that exist at a given time that have been made within a program.

What is a function? A function is a block of a code wrapped in a value. Code that performs a specific task and usually returns a value.
Give an example of a function. var x = myFunction(4, 3);
What is a side effect? Is any application state change that is observable outside the called function other than its return value.
Give an example of a function that produces a side effect and another function that produces a value: Prompt or log are examples of functions which result in side effect. A pure function produces no side effects, which means that it can’t alter any external state. A. Example of side effects Making a HTTP request, Mutating data, Printing to a screen or console, DOM Query/Manipulation.B. Pure function produces no side effects, and produces a value such as Var sum = 9+1.

What is control flow? you can use to incorporate a great deal of interactivity in your application.

What is conditional execution? Conditional execution means that some part of the code is going to be executed only if certain condition
What kind of keyword do you need to use to invoke conditional execution? if, else, else if

Binding, Functions and Control Flow - Reading Assignment

1. What is an expression?
An expression is any piece of code that returns a value. You can have expressions within expressions.

2. What is binding?
Binding is another name for variable. You can use the = operator to assign a value or expression to a binding (or variable).

3. What is an environment?
The collection of bindings and their values at any given time is called the environment.

4. What is a function?
A function is a named section of code that performs a certain task. After defining a function, you can call it as many times as you want. Functions can have functions within the function. Functions can also return a value. Some functions don't return anything. Some functions have no parameters and others have 1 or more that are required for the function to execute.

5. Give an example of a function.
console.log("Hello World")
The console.log function outputs information to the console. In this example, Hello World will be displayed on the console.

6. What is a side effect?
In the previous example, the function doesn't return anything because it has a side effect - printing to console.

7. Give an example of a function that produces a side effect and another function that produces a value.
See question 5 for an example of a function with a side effect.
Other functions, like Math.max, take any amount of parameters, and returns the highest number.
Math.max(2,100,50) would return 100.

8. What is control flow?
Control flow is the order in which individual statements, instructions, or function calls are executed or evaluated.

9. What is conditional execution?
A statement that controls the flow of execution depending on some condition.

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

  • if
  • else
  • elseif
  • switch
1 Like
  1. What is an expression?
    Piece of code that results in a value

  2. What is a binding?
    Tying a value or string to a variable

  3. What is an environment?
    All of the bindings in existence

  4. What is a function?
    A reusable block of code that can be executed as needed.

  5. Give an example of a function.
    function doubly(num) {
    return num*2;
    }

  6. What is a side effect?
    Showing a dialog box, writing text to the screen or a change to 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.

    function doublyWithSideEffect(num) {
    alert(“Side effect”);
    return num*2;
    }

    function doubly (num) {
    return num*2;
    }

  8. What is control flow?
    the direction/flow of instructions within a program.

  9. What is conditional execution?
    Using conditional logic to control what parts of a program execute

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

1 Like

1. What is an expression?
It is a fragment of code that produces a value. Expressions can contain expressions as well and as analogy with human languages, an expression is a fragment of a sentence which is the statement and a program is a list of statements.
2. What is a binding?
It is how JavaScript holds values, the keywords used for that purpose are let, const or var. The difference between let, const and var is about the life cycle of the value : let and const let the value visible per block of code, however var lets the value visible for all code long.
3. What is an environment?
It is the collection of bindings and their values that exist at a given time.
4. What is a function?
It is a piece of program which returns a value or performs a task.
5. Give an example of a function?
Math.max(5, 7);
6. What is a side effect?
It is mainly a semantic error where a statement could change 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.

• Side effect : alert (“This is great”);
• Value : Math.min(7, 8);

8. What is control flow?
It is the order in which the statements are executed, from top to bottom.
9. What is conditional execution?
It is done when a condition appears with the keyword if and the program execution can take the same or another set of statements depending on the condition.
10. What kind of keyword do you need to use to invoke conditional execution?
The principal keyword is if followed by else or else if.

1 Like
  1. A fragment of code that produces a value is called an expression.
  2. Binding is a way for a computer the remember something with a value.
  3. The collection of bindings and their values that exist at a given time is called
    the environment
  4. A function is a piece of program wrapped in a value
  5. console.log(“This is a print function”)
  6. side effect is a function’s behavior other than returning values.
  7. alert(); - side effect, math.max(1,2); - value
  8. Control flow is the programs execution order, in our case, it’s top to bottom.
  9. Conditional execution is a statement that binds the control flow to a condition for the different path it should take.
  10. “if” and if need “else”.
1 Like

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

2. What is a binding?
Is a pointer to a value in memory.

3. What is an environment?
Is a collection of bindings that hold some values that are create when the system execute. This bindings allow access information or interact with the surrounding system.

4. What is a function?
Is a piece of code wrapped with brackets. When it is invoke, every row of that code is executed, then maybe some value is return. A function can be just declared or hold in some binding.

5. Give an example of a function.

var smartContract = function(value) {
    var amount = 100;    

    return amount + value;
}

6. What is a side effect?
Is the any other result of a function than not be the return of a value.

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

Function that produce a side effect:

console.error('The program is wrong.');

Function that produce a value:

Math.max(1, 3, 8);

8. What is control flow?
The program normal flow is to run every code row, one after other, from top to bottom. There are some statements that allow change the normal flow, therefore control flow of program.

9. What is conditional execution?
When there are two or more branching road in a program, and the proper branch is take based on some situation that is verify by conditional statement.

10. What kind of keyword do you need to use to invoke conditional execution?
The follows keyword: “if”, “else”, “else if”, “switch”, “case”, “default”.

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

What is a binding?

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

What is an environment?

The collection of bindings and their values that exist at a given time is called theenvironment.

What is a function?

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. Such values can be applied in order to run the wrapped program. For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.
Give an example of a function.
prompt(“Enter passcode”);

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.

Side effect - console.log(Math.max(2, 4)); // → 4
Value - console.log(Math.min(2, 4) + 100); // → 10

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.
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.

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

If or else

What is an expression?

What is a binding?
A binding is an expression that is tied to a defined value. It analogous to a tentacle in that its job is to grab something.

What is an environment?
The environment is the term used when referring to the values ascribed to each binding at any given time.

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

Give an example of a function.
The dialogue box is an example of a function. It can be invoked by typing “prompt(“enter passcode”);”

What is a side effect?
Didn’t really understand.

Give an example of a function that produces a side effect and another function that produces a value.
The dialogue box is a side effect of a function, and the Math.max function will produce a value (the greatest number).

What is control flow?
Control flow refers to the fact that a bunch of statements will be executed from top to bottom.

What is conditional execution?
Conditional execution is when the program only executes x if a certain condition is met, such as if a number is higher than 9, then x. If not higher than 9, then y.

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

1 Like

1:fragment of code that produces a value
2 use of var to reference to other variable
3.collection of variables and their values that exist at a given time
4. Piece of program wrapped in a value , values can be applied in order to run program
5. alert (“xxx”) , console.log ("___")
6.some functions produce a side effect could be a text box
7. side effect = alert , mathmax or mathmin gives a number
8. the order of execution of commands
9. conditional execution which gives a optional path by using IF command
10: IF

1 Like
  1. An expression is a fragment of code that produces a value
  2. A binding is a thing that catches and holds values
  3. A collection of bindings and values that exist at a time
  4. A function is a piece of program wrapped in a value
  5. Prompt(‘something’);
  6. A side effect is a showing a dialog box or writing text to the screen
  7. The function that produces a value is Math.max that takes any amount of numbers and gives back the greatest Ex: console.log(Math.max(2, 4)); it gives 4
  8. Control flow executes a program that contains more than one statement as a story, from top to bottom.
  9. Conditional execution is a branching road where the program takes the branch based on the situation
  10. If is the keyword used to invoke conditional execution
1 Like