Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?

A piece of code that produces a value

  1. What is a binding?

A binding is a way connecting a term or expression to a value

  1. What is an environment?

An environment is the collection of the bindings and their values

  1. What is a function?

A function is a piece of wrapped code

  1. Give an example of a function.

prompt()

  1. What is a side effect?

Showing a dialog box or writing text to the screen

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

prompt() and console.log(Math.max(4, 5));

  1. What is control flow?

Control flow is the manner in which the program reads the code, from top to bottom

  1. What is conditional execution?

Conditional execution is when the code runs only under certain circumstances or of certain conditions are met to

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

if

1 Like
  1. What is an expression? - “A fragment of code that produces a value is called an expression.” “The simplest kind of statement is an expression with a semicolon after it. This is a program.”
  2. What is a binding? - To keep and hold on to values, Javascript creates these bindings. These bindings are designed to keep internal states or basically remember things. For example - ‘letcaught’ is a special statement that indicates a binding will occur. I like the idea the book states about bindings should be thought as ‘tentacles’ in order to grasp things, which ultimately can be let go.
  3. What is an environment? - The environment the collection of bindings and their values that exist at a given time.
  4. What is a function? - A function is a piece of program wrapped in a value. For example, a binding prompt that holds a function such as: promt(“Enter passcode”);
  5. Give an example of a function.
  6. What is a side effect? - It’s an expression that could affect the internal state of a machine in a way that affects 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. - An example is ‘math.max’, which is a function that takes any amount of number arguments and then gives back the greatest. Ie - console.log(Math.max(2, 4)); // - 4
  8. What is control flow? - Is when your program contains more than one statement and those statements are executed as if they are apart of a story flow, from top to bottom.
  9. What is conditional execution? - Since not all programs follow a straight path, as such paths may branch out, and the program follows the proper path for the given situation at hand. This is deemed a ‘conditional execution.’
  10. What kind of keyword do you need to use to invoke conditional execution? - The ‘if’ keyword in Javascript. It’s like in the English language and conditional statements are always started with the word ‘if’.
1 Like
  1. What is an expression?

A fragment of code that produces a value.

An expression between parentheses is also an expression, as is a binary operator applied to two expressions or a unary operator applied to one. Expressions can contain other expressions.

  1. What is a binding?

It is a variable. To catch and hold values.

For example, the keyword - let - indicates that this sentence is going to define a binding. It is followed by the name of the binding, and if we want to immediately give it a value, by an = operator and an expression.

After a binding has been defined, its name can be used as an expression.

  1. What is an environment?

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

  1. What is a function?

It is a block of code designed to perform a particular task. Executing a function is called invoking, calling, or applying it. You can call a function by putting parentheses after an expression that produces a function value.

When a function produces a value, it is said to return that value. Anything that produces a value is an expression in JavaScript, which means function calls can be used within larger expressions.

  1. Give an example of a function.

prompt(“Enter password”);

  1. What is a side effect?

Side effects are any state changes that can be seen outside of a function call with the exception of the function return value.

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

Prompt produces a dialog box which is a side effect. Math.max, Math.min functions will return a value.

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

  1. What is conditional execution?

It refers to the situation where we want to create a branching road in which the program takes the correct road depending on the situation at hand. In this case, there might be different outcomes based upon a previous execution.

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

If, else.

1 Like
  1. An expression is a piece of code that produces a value.

  2. A binding is a word that stores a value.

  3. An environment is the collection of bindings and their stored values at a given time.

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

  5. console.log() is an example of a function that prints its arguments to the console

  6. A side effect is something that a function can produce such as showing a dialogue box or writing text to a screen.

  7. The “alert()” function produces a side effect. The “Math.max()” function produces a value.

  8. Control flow is the way that a program executes code. In Javascript, a program is executed one line of code at a time, in order from top to bottom (or from left to right if multiple statements are written in the same line)

  9. Conditional execution allows you to jump to a specific part of the program when a certain condition is met.

  10. “if” is the keyword to invoke conditional execution in Javascript.

1 Like
  1. An expression, is anything that ends up with a value.

  2. Tentacles to attach between bag :slight_smile:

  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.

  5. prompt(“Enter passcode”);

  6. It’s what happens in the screen, after we activate a function, like a pop-up.

  7. prompt(“Enter passcode”); == side effect; console.log(“this is value”);

  8. It’s the way we attach between bindings n values.

  9. how things cascade from a statment to another, like a story.

  10. If, Else 


1 Like

Reading assignement homework answers:

1. Expression is the simplest kind of statement, any fragment of code that produce a value is an expression!

2. Binding is the second kind of statement that catch and stores an values from their expressions

example:

var car = "Ford";
console.log(car);
//

special words like var let const indicates a biding(variable), special word followed by the biding name and equal operator and a value we want to store

after we create a biding, We can use it as expression

(keywords may not be used as biding name)

examples:

let five = 5;
console.log(five*five);
//

//or
let a = (5/2.5);
let b =(10*1.5);
console.log(a+b);
//

we can also change the var name after we create it


let color = red;
console.log(color);
//
let color = blue;
console.log(color);
//

//or
let a = 10;
let b = 2;
console.log(a*b)
//
let b = 5;
console.log(a*b);

3. Environment is collection of bidings(variables) and their values that exicst !
When program starts the environment always contains bindings(variables) that are part of the language standard like in the browser


4. Function is a piece of program wrapped in a value.
for example in a browser environment , the biding alert holds a function that shows little alert box with a value(argument) written in parentheses

executing the function is called invoking or calling it


5. Function examples:

alert("value");
//

//or another binding holds a function that shows a dialog box asking for some input

prompt("Enter your full name:");
//

6. Side effects is an expression(statement) that could affect the internal state of the machine

side effects is the dialog box, alert or writting text to the screen. in other words is a statement result that changes something that affects the program


7.
example of a function that produces a side effect:

alert("some value");

//or

prompt("some value");

example of a function that produce a a value:

console.log(math.min(1,3,7,9));

//or

console.log(math.min(3,5));

8: Control flow is the way the program executes the code, the statements of the code are executed from top to bottom like a book at least in Javascript :smiley: 


9. Conditional execution is like creating a branching road in which the program code takes the correct road depends on the situation (the conditions) at the road
and the cods runs only under certain conditions


10. The keyword is if :grinning:

i would like to mention my english grammar is not so good and It took me a while to finish these homework all day :innocent:

1 Like
  1. Every piece of code that produces a value is an expression. Litterally every value or multiple and nested value or strings are expression.

  2. JS provide bindings or variables to grasp a value for testing and dont lose that through the code execution.

  3. Every bindings and their connected values that exist at a given time is called the environment. When you start new script in JS that’s not empty. Yet contains bindings that are part of the language standard, and bindings that provide ways to interact with the surrounding system.

  4. A function is a piece of program wrapped in a value, in order to run the program’s code at some point without typing the whole script. You can call (invoke or apply) a function writing parentheses after an expression that produces a function. Usually we use directly the name of the bindings that holds function value. The values between the parentheses are called arguments that you feed to the program inside the fuction.

  5. console.log("I'm the number " + String(1))

  6. Side effects are code in a function that makes changes to things that are outside the function. A statement can changes the internal state of the machine in order to affect the statements that
    come after it. The side effect is this change in the interal state of the machine.

  7. side effect functions console.log(prompt("Enter here your seed phrase and.. brr"));
    value functions String(Math.max(9 , 10))

  8. The direction for the execution of the script in JS when you have more than one statement. The statements will be read as if they are a story, from top to bottom.

  9. When in the control flow could grow a branch if the condition previously declared are present.

  10. You can invoke conditional execution and so interupt the flow of control and create a possible branch by using : if, else, and switch; and while, do, and for for looping statements.

1 Like
  1. What is an expression?

Any code that expresses some kind of value. String or number or true/false.

  1. What is a binding?

A binding creates a variable that stores value to memory.

  1. What is an environment?

The set of variables and values stored in the memory.

  1. What is a function?

A clearly defined logic inside the code that executes a certain logic.

  1. Give an example of a function.

function ThisIsAFunction(){
a = 4; b = 5;
c = a + b;
prompt©;
}

  1. What is a side effect?

Displaying a value is a side effect. only initializing a variable is only a statement, but alerting it 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.

function SideEffect(){
a = 4;
alert(a);
}

function CalcC(){
a = 4;
b= 4;
c = a* b;
}

  1. What is control flow?

Control flow is when a program runs through statements in a linear way.

  1. What is conditional execution?

Conditional execution is when a program will execute different code depending on the outcome of a condition.

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

if, elseif, else

1 Like
  1. What is an expression?

A section of code that produces a value

  1. What is a binding?

A binding represents the connection of a variable to its value

  1. What is an environment?

The accumulation of variables, bindings and values present in memory.

  1. What is a function?

A piece of code embedded in the program as a value that can be called in multiple places.

  1. Give an example of a function.

prompt(“What’s your name?”);

  1. What is a side effect?

The visual production of something executed by the code; IE an output to console.

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

side effect:
console.log(“Hi there”);

value:
1+2

  1. What is control flow?

The order in which operations within the script are run by the machine. In basic terms it is top to bottom, with conditions, loops or breaks altering the flow if required.

  1. What is conditional execution?

An IF statement determines on a boolean basis if the provided expression is true or false, and executes the assigned expressions according to the results of that evaluation.

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

if or while

1 Like
  1. An expression is a fragment of code that produces a value. It can be constructed as an expression with many expressions within it to create a larger complex expression. Sort of like a math problem that can have smaller problems to be solved within it.
    2.Bindings allow for you to give a set value to a variable. For example the expression let x=43; sets the value of x to 43. So later on when creating the expression (x*21) will yield 903.
  2. Am environment is the collection of bindings and their values that exist at any given time.
  3. A function is a smaller program wrapped in a value. There is usually an expression that you would invoke that produces the function value.
  4. The most common function we have learned up until this point is the prompt function which prompts for an input from the user.
  5. A side effect is a dialogue or written text shown to the screen that is a result of a function.
  6. An example of a function that produces a side effect is the console.log function which prints text to the screen. An example of a function that does not yield side effects is the Math.min() as it simply returns the smaller of the arguments presented within the function.
  7. Control flow is the order in which the statements you give to a program are executed. They are usually performed top to bottom. Being in the first statement will be executed followed by the second statement.
  8. Conditional execution is used when you want to create a fork in the statements executed based on the situation at hand. Based on the situation one statement will be executed rather than the other.
  9. The keyword if is used in this scenario.
1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is an assignment of a value to a variable
  3. An environment is a collection of bindings and values that exist at a certain point
  4. A function of a bit of code wrapped in a value
  5. Console.log(“foo”)
  6. A side effect is an output or behavior of a function separate from its return value.
  7. console.log() has a side effect of writing the value to the log.
    Math.abs(-456.321) is a function that returns the absolute value of the argument
  8. Control flow is the execution path of a program
  9. Conditional execution is a construct where code will (or will not) be executed based on the result of a defined condition
  10. if, else if, else
1 Like
  1. What is an expression?

An expresion is any fragment of code that results in a value.

  1. What is a binding?

A binding or a variable is assignment of internal state used to catch and hold values.
By using the keyword let before defining a variable lets JavaScript
know the sentence is going to define a variable.

  1. What is an environment?

The enviroment is the collection of bindings and their values existing in a given instance.

  1. What is a function?

Function is a section of the program that performs a specific task.
It can then be called upon for use in other expressions.

  1. Give an example of a function.

alert('This is alert message);

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

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

alert(‘Alert is a function that produces a side effect’);
console.log(6+4); function that produces a value.

  1. What is control flow?

Control flow is the order in which a program will execute the code.

  1. What is conditional execution?

Control flow is the order in which we code and have our statements evaluated.

Conditional execution means that a condition is only executed
when it meets predefined condition.

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

if
else
else if
switch

1 Like

Great answers. It’s easy to understand. Great work. :clap:

Carlos Z.

  1. Is a piece of code that produces a value.

  2. Binding store value, same as variables and constants.

  3. Is a collection of binding and their values at a given time.

  4. A piece of the program wrapped in a value. Executing functions is called invoking, calling, or applying it.

  5. console.log(“x”); function outputs its argument.

  6. Is the output of a function separate from its value.

  7. Example of the function that produces side effect:
    prompt(“This is a side effect.”);
    Example of the function that produces a value:
    Math.max(1, 2, 5);

  8. Is a way that the program executes code, it executes statements from top to bottom.

  9. A conditional execution is an execution that code gets executed only if it meets certain conditions.

  10. The keyword IF.

1 Like
  1. Expression is code to assign value to a variable and to have value
  2. Bindings catch and hold values
  3. Environment is the collection of Bindings and values within a program
  4. Function - preform tasks / a piece of program wrapped within a value
  5. Function example- function myFunction(p1, p2) {
    return p1 * p2; // The function returns the product of p1 and p2
    }
  6. is a function outside of its scope/dialogue box
  7. prompt(“How many Pounds”) Console.log(2+2);
  8. The order of Code
    9.sequence of Code based on Values
  9. If and ELSE / and variations
1 Like

@thecil thank you very much :hugs: appreciate your feedback :ok_hand:

1 Like
  1. What is an expression?

A fragment of code that produces a value; every value written literally; this includes numbers, strings, binary and unary operators.

  1. What is a binding?

A binding ‘grabs hold of’ and stores a value, eg using ‘let,’ ‘const’ or ‘var’, once a binding is defined it can be referred to by its name which is then an expression.

  1. What is an environment?

The collection of bindings and their values at a given time, whether as part of javascript language itself, or entered manually by the programmer.

  1. What is a function?

A piece of program wrapped in a value, they can be applied to run the wrapped program.

  1. Give an example of a function.

‘prompt’

  1. What is a side effect?

The effect of a statement on following statements.

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

Side effect: prompt, console.log. Value: Math.max, Math.min

  1. What is control flow?

Multiple statements are executed top to bottom.

  1. What is conditional execution?

Where the program will execute along different paths depending on whether certain conditions are met

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

‘If/else’

1 Like
  1. What is an expression?
    An expression is any fragment of code.
  2. What is a binding?
    A binding or a variable is assignment of internal state used to catch and hold values. By using the keyword let before defining a variable lets JavaScript know the sentence is going to define a variable.
  3. What is an environment?
    The enviroment 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. It can be executed by calling it.
  5. Give an example of a function.
    function returna(a)=>{ a};
  6. What is a side effect?
    A side effect is a function which produces an expression and returns that value.
  7. Give an example of a function that produces a side effect and another function that produces a value.
console.log(firstAccount);
var firstAccount = accounts[0];
  1. What is control flow?
    It is the direction of execution of code in JavaScript which happens in a top down approach.
  2. What is conditional execution?
if(typeof web3 !== "undefined")
else{alert("Could not find Web3.0 provider. Please visit metamask.io or download the Ethereum Mist browser");
  1. What kind of keyword do you need to use to invoke conditional execution?
1 Like
  1. fragment of code that produces a value
  2. binding or variable hold (or grasp) onto a value (defined by the programmer)
  3. collection of bindings and their values at a given moment in time
  4. piece of a program wrapped in a value
  5. prompt(“enter passcode”); will return a dialog box asking for an input
  6. the result of a function, such as a dialoge box or written text
  7. console.log produces the side effect of a dialog box. the function “math.min” produces a value.
  8. when a program contains more than one statement, the statements are executed from top to bottom.
  9. when a function results in the opportunity of more than one path. “if, then”
1 Like
  1. A fragment of code that produces a value.

  2. Bindings are there to catch and hold values. They are connectors to value but not he value itself.

  3. It is a collection of bindings and values accessible to JavaScript at any time.

  4. It is a wrapped set of values in such a way so that they run as a computer program

  5. console.log(“hello”) ;

  6. Show a dialog box or writing text to screen is a side effect

  7. Side effect: prompt(“anything”)
    function that produces value: console.log(math.max(2 , 4)) ;

  8. If we have more than one statement, they are executed from the top to bottom.

  9. When we want to create branches of execution.

  10. if, else

1 Like