Binding, Functions and Control Flow - Reading Assignment

What is an expression?

An expression is a piece of code that creates a value. It can contain expressions within itself and it is usually part of a more complete code, a statement.

What is a binding?

Bindings are how variables are declared or defined.

What is an environment?

An environment is the collection of bindings and their values, the world in which future expressions will refer to.

What is a function?

An function is a piece of program wrapped in a value. They are executed to produce a result

Give an example of a function.

Console.log is an example of a function.

What is a side effect?

This is when a dialog or text appears on the screen.

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

Prompt() would produce a side effect and Math.max() would return a value.

What is control flow?

This is the order of operations of how statements are read and executed by the program. This is usually done from top to bottom.

What is conditional execution?

This is when if/else statements are used to see if certain conditions are being met and how to proceed based on those different conditions.

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

IF.

1 Like

What is an expression?

  • a code statement that produces a value

What is a binding?

  • a stored value (ie. a variable assignment)

What is an environment?

  • a collection of bindings and their values

What is a function?

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

Give an example of a function.

  • console.log()

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.

  • alert(“Nailed It!”);
  • console.log(1+2);

What is control flow?

  • dictates the order in which statements are processed

What is conditional execution?

  • execution order and path based on operating conditions

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

  • if
1 Like
  1. What is an expression?
    

a set of instructions for the computer to execute

  1. What is a binding?
    

assigning a value to a variable

  1. What is an environment?
    

Where your program is able to run

  1. What is a function?
    

a set of instructions that can be re-used with different values passed into it

  1. Give an example of a function.
    

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

  1. What is a side effect?
    

Something that appears on the screen such as a prompt

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

Side effect
function checkBTCValue(BTCValue){
if (BTCValue >= 1000000){
alert(“John Mcafee doesn’t have to eat his **** on TV!”);
}
}

Value
function addNumbers(x, y){
return x+y;
}

  1. What is control flow?
    

The order in which the statements are executed in a program

  1. What is conditional execution?
    

an action that will only be performed if certain conditions are met

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

if / else if / else

1 Like

What is an expression?
An expression is a piece of code that produces a value
What is a binding?
Binding is a way of linking a value to variable.
What is an environment?
A collection of bindings and their values that exists at a given time
What is a function?
A piece of code that takes arguments to compute and returns a value based on the given arguments
Give an example of a function.
console.log(" This is a fucntion");
What is a side effect?
Side effects are expressions or functions that displays or change something outside of its own scope.
Give an example of a function that produces a side effect and another function that produces a value.
console.log(Math.max(2,4));
What is control flow?
A path that a program follows
What is conditional execution?
Conditional excecutions are a set of steps that are followed depending of the conditions of the program
What kind of keyword do you need to use to invoke conditional execution?
If, else, while, do loop

1 Like
  1. A fragment of code that produces value.
  2. A special statement that holds value.
  3. Collection of bindings and their values.
  4. Piece of program wrapped in a value.
  5. console.log(“hello”)
  6. Side effect is when functions produce value.
  7. console.log(“Side Effect”); VS. Math.max(2,5);
  8. The way how program gets executed from top to bottom
  9. Conditional execution can omit some piece of code from control flow i.e. does not get exectued.
  10. IF, SWITCH, WHILE, FOR, DO WHILE.
1 Like

1. What is an expression?
A piece of code used to product a value.

2. What is a binding?
A way to remember a value.

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

4. What is a function?
A piece of code that performs a task

5. Give an example of a function.
console.log(“hello world”);

6. What is a side effect?
when the code products something you can see

7. Give an example of a function that produces a side effect and another function that produces a value.
alert(“this is a side effect”);
(“hello” + " " + “world”);

8. What is control flow?
The order which the code is executed

9. What is conditional execution?
when you give instructions for the code to execute in different ways, if they comply with certain rules you have stated

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

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

  2. What is a binding?
    It stores the value / basically bind the value to a name.

  3. What is an environment?
    A collection of bindings and their values that exist in code line.

  4. What is a function?
    A piece of programming code that performes certain tasks.

  5. Give an example of a function.
    console.log(“ETH will moon”);

  6. What is a side effect?
    When code get executed you get side effect basically a result on the screen.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    prompt(“Don’t write anything here”);
    (“This is a value”);

  8. What is control flow?
    It is the order in witch statements are being executed usually it is from top to bottom

  9. What is conditional execution?
    The condition that you give to your program to execute the code and it has to meet he conditional rules.

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

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

What is a binding?
a valiable, some to catch and hold values

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

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

Give an example of a function.
function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2
}

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.

Give an example of a function that produces a side effect and another function that produces a value.
Produces a side effect:
prompt(“Enter passcode”);

Produces a value:
Math.max(2, 4)

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

What is conditional execution?
execution of one code path for condition1 and another code path for condition2

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

1 Like

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

2. What is a binding?
Binding assigns a value, such as to a variable or constant, that will be held and can be called upon later

3. What is an environment?
All of the bindings and values that exist in a given moment. Different programs will have different starting environments. So they will have things such as bindings that will understand mouse or keyboards commands, etc…

4. What is a function?
A function is a bit of program assigned to a value. When the value is called it will run the program.

5. Give an example of a function.
The “alert” prompt is assigned a bit of code that will cause a notification box to popup with a message
alert(“Post This Message”); - this will display the message between the quotes in a popup.

6. What is a side effect?
A side effect is something useful a function does, such as open up a dialogue box.

7. Give an example of a function that produces a side effect and another function that produces a value.
My answer from question #5, produces the side affect of opening up a popup box: alert(“Post This Message”);
Math.max is a function that returns the greatest value of the numbers given:
console.log(Math.max(4, 18, 16));
// -> 18

8. What is control flow?
Flow control is making sure that the code flows in the order you want, such as a straight line or with branches in which the direction followed could depend upon the input.

9. What is conditional execution?
This is where code will be executed if certain conditions are met.

10. What kind of keyword do you need to use to invoke conditional execution?
Keywords like “if” and “else” are used for conditional execution.

2 Likes

What is an expression?
The code that produces a value.
What is a binding?
A way to define a value with any given name and use that as a expression
What is an environment?
collection of bindings and there values
What is a function?
a program in a certain value.
Give an example of a function.
input number, if number < 10 output “Low”, if number < 100 output “Medium”, else output “Large”
What is a side effect?
any other output then a value
Give an example of a function that produces a side effect and another function that produces a value.
input num = number “any number under 10”, if num > 10 output “idiot”, else output “thanks”
console.log(math.max(2,4));
What is control flow?
the order in which multiple statements are treated by javascript
What is conditional execution?
when a program gives a output according to the current state.
What kind of keyword do you need to use to invoke conditional execution?
“if” or “else”

1 Like
  1. What is an expression?
    • Fragment of code that produces a value.
    • Every value that is written literally such as 22 or “kjlkj”
    • Expression can contain other expressions, similar to subsentences.
    • Allow us to bind expressions.
  2. What is a binding?
    • To hold values. It grasps values that it has a reference to. A temtacle.
    • Let, var, const
  3. What is an environment?
    • Collection of bindings and their values that exist at a given time.
  4. What is a function?
    • Lot of default environment have the type function.
    • 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(“”);
  6. What is a side effect?
    • After using a function the dialog box or written text is a side effect.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Alert(;lkj); produces side effect. Math.max produces a value.
  8. What is control flow?
    When a program contain more than one statement the program is read top to bottom. `
  9. What is conditional execution?
    Conditional execution is if we want to create a branching road like if then conditional.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If.
1 Like

1.Click for Expression reference

In Javascript:
"An expression is any valid unit of code that resolves to a value.

Conceptually, there are two types of expressions: those that assign a value to a variable and those that simply have a value. The expression x = 7 is an example of the first type. This expression uses the = operator to assign the value seven to the variable x. The expression itself evaluates to seven. The code 3 + 4 is an example of the second expression type. This expression uses the + operator to add three and four together without assigning the result, seven, to a variable.

JavaScript has the following expression categories:

Arithmetic: evaluates to a number, for example 3.14159. (Generally uses arithmetic operators.) String: evaluates to a character string, for example, “Fred” or “234”. (Generally uses string operators.) Logical: evaluates to true or false. (Often involves logical operators.) Object: evaluates to an object.

2.Click for Binding reference
Binding generally refers to a mapping of one thing to another. In the context of software libraries, bindings are wrapper libraries that bridge two programming languages, so that a library written for one language can be used in another language.

  1. Environment
    In computer program and software product development, the development environment is the set of processes and programming tools used to create the program or software product. The term may sometimes also imply the physical environment.

  2. Function
    In programming, a named section of a program that performs a specific task

  3. Example of a funtion

Function encrypted() private {
creator = msg.sender;
}

  1. What is a side effect?
    In computer science, a function or expression is said to have a side effect if it modifies some state outside its scope or has an observable interaction with its calling functions or the outside world besides returning a value. For example, a particular function might modify a global variable or static variable, modify one of its arguments, raise an exception, write data to a display or file, read data, or call other side-effecting functions

value:
const square = function(x) {
return x*x;
};
console.log(square(10));
// - > 144

side effect:
const makeNoise = function() {
console.log(“Pling!”);
};
MakeNoise();
//-> Pling

  1. control flow
    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.

let theNumber = Number(prompt(“Pick a number”));
console.log("Your number is the square root of " +
theNumber * theNumber);

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. We might, for example, want to show the square of the input only if the
input is actually a number.

let theNumber = Number(prompt(“Pick a number”));
if (!Number.isNaN(theNumber)) {
console.log("Your number is the square root of " +
theNumber * theNumber);
}

the “if” statement

2 Likes
  1. a fragment of code that produces a value
  2. a binding catches and holds values so that they can be used later on
  3. the collection of bindings and their values that exist at a given time
  4. a piece of program wrapped in a value
  5. function add_one(value) { return value+1; }
  6. side effects in the program make something observable happen
  7. side effect prompt(“say something”);
  8. the order in which our code is executed (top to bottom)
  9. a selected part of our code is only executed under a certain condition
  10. if / else
1 Like

What is an expression?
An expression is a piece of code that produces a value.
What is a binding?
A binding is a piece of code, or keyword, that catches and holds values.
What is an environment?
The environment is the bindings and values that exist at a given time.
What is a function?
“A function is a piece of program wrapped in a value.”
Give an example of a function.
prompt(“Enter passcode”);
What is a side effect?
Having a dialog box or text show up on 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: >>var h = “hello”; alert(h);
function that produces a value: >>console.log(Math.max(2, 4));
What is control flow?
Control flow is from top to bottom.
What is conditional execution?
This isn’t necessarily executed from top to bottom but could have branch executions.
What kind of keyword do you need to use to invoke conditional execution?
‘if’ is a conditional execution keyword.

1 Like
  1. An expression is anything that expresses a value

  2. Binding is assigning values to the variables

  3. Environment is all variables, values and expressions

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

  5. Math.max(a,b)

  6. A side effect is when the function modifies a variable or alters a state of something else outside its scope

  7. console.log(math.min(a,b));

  8. Statement execution order

  9. When a certain action is executed only if certain conditions are met.

  10. IF

1 Like
  1. expression = piece of code that returns a value
  2. binding = the connection between the value and the tag
  3. enviroment = all the binding available at the given time
  4. function = a piece of program wrapped in a value
  5. console.log (“hi there!”)
  6. side effect = changing the internal state of the machine in a way that will affect the statements that
    come after it
  7. console.log(“aaaah!”) ; Math.max(1,2,3,4);
  8. Control Flow = the order in which the code is executed.
  9. Conditional execution = when the code has to respect a condition in order to be executed
  10. IF, IF…ELSE
1 Like
  • What is an expression?
    fragment of code that produces a value
  • What is a binding?
    To catch and hold values
  • What is an environment?
    The collection of bindings and their values that exist at a given time
  • What is a function?
    A function is a piece of program wrapped in a value
  • Give an example of a function.
    prompt(“Enter passcode”);
  • What is a side effect?
    Showing a dialog box or writing text to the screen is a side effect
  • Give an example of a function that produces a side effect and another function that produces a value.
    alert(“hello”);
    console.log(Math.max(2, 4));
  • 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?
    where the program takes the proper branch based on the
    situation
  • What kind of keyword do you need to use to invoke conditional execution?
    Conditional execution is created with the if keyword
1 Like
  1. a part of the code. When a statement corresponds to a full a sentence, an expression is a part of a sentence.

  2. a binding helps to keep an internal state, it helps to remember by catching and holding values.

  3. a collection of bindings and their values

  4. a piece of program wrapped in a value

  5. console.log

  6. functions can produce side effects, which could be sth like showing a dialog box

  7. promt - produces a dialog box / console.log - returns a value

  8. When a program has more than 1 statement. If there are more statements, it flows from 1 statement to the next

  9. If there are more than 1 pathways, meaning there are more than 1 different options, it executes depending on the variable pathway.

  10. keyword if or else

1 Like

What is an expression? value produced by a fragment of code

What is a binding? tentacles that catch and hold values (or variable)

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

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

Give an example of a function. console.log

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

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

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? where the program takes the proper branch based on the situation at hand.

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

1 Like

1.a fragment of code that prodeuces a value is an expression
2. is a program that keeps the caught uses it to grab hold of the values
3.the collection of bindings and their values that exist at a given time
4.is a piece of program wrapped in a value
5.for example console.log () or function name(p1,p2){} or function Function(f,h){ return fh}
6.a change in state outside of the immediate context
7.5>4 side effect var multiply=9
1; produces a value
8.to put the executions and statements in order
9. if keyword or a program executes on based on conditionals
10.if and else

1 Like