Binding, Functions and Control Flow - Reading Assignment


#142
1. -A fragment of code that produces a value is called an expression
2. -Bindings is helpful for catching and holding values for future use

3. -The collection of bindings and their values are called an environment

4. A function is a piece of program wrapped in a value
-for example a dialogue box asking for a password
-executing a function is called invoking, calling or applying it

5. -in a browser environment a binding prompt holds a 
Function that shows a little  dialogue box asking for an input
6. -a side effect is a possible return output from a function - for example showig a dialouge box or showing text on the screen
7. -side effect example is :  for example showing a dialogue box or showing text on the screen
-value example: the math.max funtion takes any amounts of a number of arguments and outputs the greatest as the value
8. -is the order of program execution is top to bottom
9. Conditional execution is executed with the "If" keyword in JS  to execute if and only if certain conditions hold.
10. If, else

#143
  1. Expression is a fragment of code that produces a value.

  2. Binding is a variable which gets & holds a place for values.

  3. Environment is a collection of bindings and their values at a given time.

  4. Function is a group of statements, (piece of program, block of code,…) designed to perform a particular invoked task.

  5. function myFunction (x1, x2) {
    return x1 - x2;
    }

6.Side effect is when hidden statement(s) affect the statements which will come later in a code, and by doing so makes changes.

a) function with side effect
def plusWithSideEffects(x, y) { alert(“This is a side effect”); return x + y; }
b) example of a function that produce a value is I think a function under my answer No. 5

  1. Control flow is an execution of statements in order.
  2. Conditional execution is made when a code has branches, when more paths of an execution are possible. Which execution will be done depends on a what conditions are met (or not).
    10.if, else, …

#144
  1. What is an expression?
    A fragment of code that produces a value. Examples of expressions include a value that is written literally, an expression between parentheses, a binary operator applied to 2 expressions or a unary operator applied to one expression

  2. What is a binding?
    A binding is the mechanism by which a program keeps (stores) (points to) 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.
    Console.log, prompt

  6. What is a side effect?
    A side effect is a statement that affects the world. For example, it could display something to the screen or change the internal state in a way that will affect future statements.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Console.log is an example of a function that produces a side effect; math.max is an example of a function that produces a value

  8. What is control flow?
    The order in which individual statements, instructions, function calls of a program are executed or evaluated

  9. What is conditional execution?
    Conditional execution means the program can take different branches or paths based on the current situation. This is made possible by conditional statements or expressions.

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


#145
  1. fragment of code that produces a value
  2. variable that points to a value
  3. collection of bindings and their values that exist at a given time
  4. piece of program wrapped in a value
  5. prompt(“Enter passcode”);
  6. changes in the internal state of the machine or changes the world
  7. prompt(“Enter passcode”); Math.max(2, 4);
  8. the order in which statements are executed
  9. a condition must be met for the subsequent statements to be executed

#146

What is an expression? → A fragment of code that produces a value. An expression is kind of like a sentence fragment whereas a Javascript statement would be a full sentence. A program is a list of statements.
What is a binding? → Triggered by “let”, “const”, and sometimes “var”, it allows us to catch and hold values. “Const” will point at the same value as long as it lives.
What is an environment? → The collection of bindings and their values that exist at a given time.
What is a function? → A piece of program wrapped in a value. Values given to functions are called arguments.
Give an example of a function. → prompt(“Enter passcode”);
What is a side effect? → Showing a dialog box or writing text to a 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(Math.max(2, 4));
What is control flow? → The order in which the statements are written and executed.
What is conditional execution? → Allows us to create a branching road in which 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”


#147

What is an expression? An expression is any code that outputs a value when executed
What is a binding? A binding lets name something and then set it = to an expression. It holds onto that value unless changed.
What is an environment? An environment is all of the binding that are present when you open a program.
What is a function? A function is a a set of instructions for the computer to follow to get to a value.
Give an example of a function. (Math.max) this function outputs the highest of whatever values are included in the function.
What is a side effect? When you execute a program and something happens aside from the output you were looking for. Such as seeing something on a screen or a change in the program.
Give an example of a function that produces a side effect and another function that produces a value.
Console.log produces text in the console as a side effect and Math.min produces an intended value.

What is control flow? The way that blocks of code are structured with statements in a specific order to run the program.
What is conditional execution? When a program is executed only if certain conditions are met within the program.
What kind of keyword do you need to use to invoke conditional execution? if or else


#148

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

A binding (or variable) is something that catches or holds values.

An environment is a collection of bindings and their values that exist at a given point in time.

A function is a piece of programming that can be called or invoked to perform and action or a calculation.

Function can be native to javascript or user defined. An example of a native javascript function is Math.max() which can be fed any quantity of numbers and will return the largest one.

A side effect is an action which happens during execution of function code, such as opening a dialog box or displaying a value.

An example of a function that produces a side effect is Alert().
An example of a function that returns a value is Math.min().

Control flow is the order in which a program is executed. It may be linear or not.

Conditional execution is the altering of control flow by using an IF statement. IF True, execution may proceed down a particular path. IF False, execution may proceed down a different path.

The IF keyword is used to invoke conditional execution.


#149
  1. Expression is part of the code that produces value.
  2. With binding we can catch and hold values needed in the code. Is defined by keyword ‘Let’.
  3. Environment is collection of values and their bindings in a given time.
  4. Function is part of a program wrapped in a value.
  5. console.log, getelementbyid, getelementbyclass…
  6. Side effects are pop-up boxes or text on the screen appearing due to the function being invoked.
  7. For example: prompt or console.log
  8. Control flow is order for executing the statements in the program.
  9. Conditional execution - program is executed only under certain conditions specified in the code.
  10. The keywords for conditional execution are ‘if’, ‘else if’, ‘else’.

#150

Ans to Program Structure Chapter 2

1What is an expression?
A fragment of code that provides a “value” is called and “EXPRESSION”.
Expressions can contain other other expressions.
A program is a list of expressions.

2 What is a binding?
Bindings are used to catch or hold values, by using a thing called “binding” or “variables”.

3 What is an environment?
The collection of bindings plus their values, at a given time, is called the “environment”.

4 What is a function?
A function is a piece of program wrapped in a value.
A lot of values in the default environment have a function built in.
Executing a function is called: “invoking”, “calling”, or “applying” it.

5 Give an example of a function.
A JavaScript function is a block of code designed to perform a particular task: a set of statements that performs a task or calculates a value.
var,
alert,
console.log

6 What is a side effect?
“side effects” is the product caused by an expression or statement.
It causes a change in the environment,such as, alert, prompt, function.

7 Give an example of a function that produces a side effect and another function that produces a value.
This function “prompt("Enter passcode”);” a side effect that produces a dialog box asking for a password.

8 What is control flow?
The control flow is the order in which the computer executes statements in a script.
If 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?
Not all programs go from “top” to “bottom”. Some need to pursue more than one “path”.
The program takes the proper “branch”, based on the situation at the moment. This is called:“conditional execution”.

10 What kind of keyword do you need to use to invoke conditional execution?
In JavaScript the “keyword” if invokes a conditional execution.


#151

1:A fragment of code that produces a value
2:Stored values for later use
3: A collection of bindings at any given time
4:A function is a piece of program wrapped in a value
5: Console.WriteLine("Enter Password: ");
6: Console.log(“Function”)
7:Writing text on the screen is a side effect
8: executing code from top to bottom left to right
9:executing code if one circumstance is true or false with the ‘if’ key word
10: IF


#152
  1. An expression is something a fragment of code that produces a value.
  2. A binding is a way to hold a value for something, using the let, var, or const keywords, followed by a name that is followed by the = operator and a value.
  3. An environment is the set of bindings and their values that exist in a program.
  4. A function is a piece of program wrapped in a value.
  5. Function ex: prompt.
  6. A side-effect is a new result from executing a function.
  7. An example of a function that produces a side-effect is the alert function; one that produces a value is the Math.max function.
  8. A Control Flow is the “story” that consecutive statements create.

#153
  1. A piece of code that produces a value is an expression
  2. Binding is linking a variable with some value
  3. An environment is a collection of expression and its value
  4. A function is a value that consist of number of expression
  5. prompt(“Enter the password”);
  6. Writing a piece of code which gives some results on the screen is side effect
  7. var a = 6
    console.log(a)
  8. the control of the program is sequentially which is from top to bottom
  9. The flow of program which does not follow a sequentially flow but rather uses branching or skipping or jumping of codes is called as a conditional execution
  10. " if "

#154

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:
let No_of_Apples = 5 * 5;

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.

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

7. Give an example of a function that produces a side effect and another function that produces a value.
a)
console.log(Math.max(2, 4));
// → 4
b)
console.log(Math.min(2, 4) + 100);
// → 102

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


#155
  1. What is an expression?
    An expression is a part of code that produces a value.
  2. What is a binding?
    A binding is a chunk of memory that holds a value.
  3. What is an environment?
    An environment is a set of variables and values.
  4. What is a function?
    A function is a section of program that performs a specific task.
  5. Give an example of a function.
    Date() is a function that returns the current date time.
  6. What is a side effect?
    Output to screen/dialog box 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: alert()
    Function produce a value: Math.max(, )
  8. What is control flow?
    Control flow is the sequence that the program being executed.
  9. What is conditional execution?
    Conditional execution is a control flow where program is executed when certain conditions are met
  10. What kind of keyword do you need to use to invoke conditional execution?
    if, else if, else

#156

1. What is an expression?
It’s a fragment of code that produces a value
2. What is a binding?
Also known as variable, a binding is something that allows to grasp/point to a value
3. What is an environment?
It’s a collection of bindings and their values that exist at a given time, which provide ways to interact with the surrounding system
4. What is a function?
It’s a piece of program wrapped in as a value, which can take or not arguments
5. Give an example of a function?
prompt(“Enter a name:”);
6. What is a side effect?
something that happens in the GUI as a result of a JavaScript expression
7. Give an example of a function that produces a side effect and another function that produces a value?
Side Effect: prompt("Enter passcode”);
producing a value: console.log(Math.max(2, 4));
8. What is Control Flow?
It is the order by which statements are executed
9. What is conditional execution?
It refers to a command that is only executed if a certain condition is true
10. What kind of keyword do you need to use to invoke conditional execution?
you need the ‘if’ keyword


#157

What is an expression? It’s a fragment of code (including a value that is written litterally)
What is a binding? also known as a variable, it is what allows you to catch and hold a value using an = sign.
What is an environment? a collection of binding 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(“hello world”)
What is a side effect? when a function creates a lasting change
Give an example of a function that produces a side effect and another function that produces a value. Side effect: alert(“This is a pop up”) Value: Math.max(3,8,2)
What is control flow? when a program has mutiple statements they are executed in a straight line or ‘top to bottom’
What is conditional execution? when you need the program to branch off in a certain direction dependant on the situation at hand, rather that simply running the statements top to bottom.
What kind of keyword do you need to use to invoke conditional execution? IF, ELSE


#158

1- The expression is two or several values with an applied one or several operators to give us new value.

2- Binding is when you tag a value to certain variable or state to catch and hold the tagged value.

3- The environment is a collection of binding and their values that exist at a given time

4- a function is a piece of program or several expressions wrapped in a value and hired to returns to you with a new value and it can be called any time you need it.

5- Example:

        function greet (name) {
return "Hello, " + name + "!";
}
greet ("World");
// "Hello, World!"
greet ("Ivan");
// "Hello, Ivan!"

6- the side effect is what you get something other then return other value

7- Example of Side Effect:

var class = {name: "IvanOnTech", date: 2018};
function renameclass(newName) {
class.name = newName;
console.log("Renamed!");
}
renameclass("SmartContractProgramming"); //Renamed!
class; // {name: "SmartContractProgramming", date:2018}

Example of not side effect:

var class = {name: "IvanOnTech", date:2018}
function renameClass(oldClass, newName) {
return {name: newName, date: oldClass.date}
}
var newClass = renameClass(class, "SmartContractProgramming");
newClass; // {name: "SmartContractProgramming", date:2018}
class; // {name: "IvanOnTech", date:2018}

8- Control flow is leading your code step by step to execute each statement individually one after another.

9- Conditional execution is how to execute you statement according to the conditions then what will be the result after than for example: (If) you get this class well (then) take the next one, (else) your money will be refunded and you will be out of the class.

10- (if) (else)


#159

1.An expression is any value or combination of values and operators which produces new ones.

2.A binding is a piece of code that acts as a placeholder of the expression and the values it produces.

3.An environment is the sum of bindings and their values that exists at a given time.

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

  1. let greeting = “Hello world !”;
    console.log(greeting); <----- function

6.A side effect is the impact that the execution of an expression (function) has on the environment (program) or the system on which it resides.

  1. let yourName = (prompt (“fill out your name”));

    console.log(10%3);

8.the chronological order (top to bottom) in which the the statements in a program are executed.

9 execution of a statement(s) based on conditions that have to be met, rather than the chronological execution of

  1. If

#160

What is an expression?
A construction that returns a value
What is a binding?
A value holder, variable
What is an environment?
The context where code excutes
What is a function?
A usualy smal program encapsulated under a name that returns a value
Give an example of a function.
function Square( var X ) { return x*x;}
What is a side effect?
Consequences of a function, like modifying something outside the scope of the function
Give an example of a function that produces a side effect and another function that produces a value.
-A function that logs something
-The square function
What is control flow?
The order in what instructions are executed
What is conditional execution?
Flow execution that depends on the value of variables
What kind of keyword do you need to use to invoke conditional execution?
IF THEN ELSE, SWITCH


#161

1. What is an expression?
An expression is like a sentence of code that has a value as a result.

2. What is a binding?
The method used to attach a value to a certain name. It memorizes this value so it can be called upon later on. Used with var or better yet with let. A binding can always be changed in the same way.

3. What is an environment?
All the bindings and their values used in a program.

4. What is a function?
A function is like a little program wrapped in a value. By using them you output a side effect or a new value.

5. Give an example of a function.

prompt(“enter passcode”);

This function will open up a dialogue box asking for user input.

6. What is a side effect?
In the example above. The dialogue box is a side effect. It doesn’t create a new value, it’s just the program wrapped up in the function.

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

Prompt(“Enter password”);

This gives a side effect = dialogue box.

Math.max(2, 4);

This gives a new value = 4 as it searches for the greatest value amongst the numbers.

8. What is control flow?
This means the order of how and when statements are activated. It’s basically like reading a book. i.e. Binding the number 6 to the name “six”. All code below this statement will have the option to use 6 as a value of six. Until we bind six to a different value.

9. What is conditional execution?
When a program runs it might need to make a choice. It does this by depending on the conditions the programmer gives it.

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

let theNumber = Number(prompt(“Pick a number”));
if (!Number.isNaN(theNumber)) {
console.log("Your number is the square root of " +
theNumber * theNumber);
} else {
console.log(“Hey. Why didn’t you give me a number?”);
}

In this example. The user wil see a dialogue box that says pick a number. IF he picks a number a value will be displayed giving the square root of his number. Or ELSE he will get a value that says “Hey. Why didn’t you give me a number?”.