Binding, Functions and Control Flow - Reading Assignment

Binding, Functions and Control Flow:

  1. A fragment of code that produces a value.
  2. To catch and hold values, also known as variable.
  3. A collection of bindings and there values.
  4. A function is a piece of program wrapped in a value wrapped in.
  5. Prompt(“enter password”);
  6. Showing a dialog box or writing text to a screen.
  7. Prompt(“enter password”);
    console.log(math.max(2, 4));
  8. How your code runs under different conditions or until a certain condition is met.
  9. The path the code takes when certain conditions are met.
  10. If
1 Like
  1. What is an expression?
    A fragment of code that produces a value.
  2. What is a binding?
    A binding is a way to define a value by using let, var, or const.
  3. What is an environment?
    The collection of bindings and their values at a given time.
  4. What is a function?
    A function is a piece of program wrapped in a value.
  5. Give an example of a function.
    Prompt(“abcdefg”);
  6. What is a side effect?
    A function that puts a dialog box or text on the screen.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side Effect: alert(“asdf”);
    Math.min(1213,65131,854,8431312,864,831,135,684,13,3518,9,4,31,46813,135,83,131,84684,312,18561,351,318,1)*500);
  8. What is control flow?
    The order lines of code are executed, top to bottom.
  9. What is conditional execution?
    Conditional execution is lines of code that are executed only when a certain condition is met.
  10. What kind of keyword do you need to use to invoke conditional execution?
    if, else, while, do, for
1 Like
  1. What is an expression?
    Its any fragment of code that is or produce a value.

  2. What is a binding?
    Its a variable that catch and hold a value.

  3. What is an environment?
    Its the total amount of bindings an their values.

  4. What is a function?
    Its a piece of code that can do a certain processing of an input and return a value. You can call it from anywhere in the program.

  5. Give an example of a function.
    Console.log returns the value to the console.

  6. What is a side effect?
    Its when an expression have some broader effect other than just the produced value.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    The function console.log produce a side effect. The function eval produce a value.

  8. What is control flow?
    Its the way to make sure that the statements are executed in the right order and not just from top to bottom.

  9. What is conditional execution?
    Its a branch where the execution of the code only happens if some conditions are met.

  10. What kind of keyword do you need to use to invoke conditional execution.
    IF og ELSE keywords

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

  2. What is a binding?
    is giving an element a value to be stored in it

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

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

  5. Give an example of a function.
    the console.log function

  6. What is a side effect?
    showing a dialog box or written 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 function that produces a side effect- alert(“Hello World”)
    another function that produces a value - Math.max(12,18)

  8. What is control flow?
    that if we have more than one statement, they are executed from top to bottom.

  9. What is conditional execution?
    if condition to be executed

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

1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is a way to bind a value to a name. This is also called a variable.
  3. The environment is the collection of bindings and their values that exist at a given time in a program.
  4. A function is a piece of code wrapped in a value.
  5. An example of a function is the String() function, that converts any type of value into a string.
  6. A side effect is a statement result that changes something that affects the program. Number() is an example of this, since it converts a value to a number in the environment.
  7. The function Number() produces a side effect, since it converts a value to a number in the environment. This will affect the program. The function console.log() does not produce any side effects, since it does not affect the program, but only prints the values given to it as arguments.
  8. Control flow is the direction the program runs, which statements are run at which time. In JavaScript the control flow is a straight line if you do not change it.
  9. A conditional execution is executing specific statements based on conditions in the program, for example conditions determined by boolean or logical operators.
  10. To invoke conditional execution, you need to use the “if” keyword.
1 Like
  1. What is an expression?
    A fragment of code that produces a value
  2. What is a binding?
    It catches and holds values
  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?
    A piece of programme wrapped in a value
  5. Give an example of a function.
    The binding “prompt” holds a function that shows a little dialog box asking for user input.
  6. What is a side effect?
    Showing a dialogue box or writing a text.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    The function “Math.max” produces a value.
  8. What is control flow?
    When a programme contains mor than one statement, the statements are executed from top to bottom.
  9. What is conditional execution?
    A programme 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”
1 Like

1.) An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value.

2.) To catch and hold values, Javascript provides a thing called binding or variable.

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

4.) A function is a peace of program wrapped in a valeu.

5.) In a browser, there are functions to interact with the currently loaded website and to read mouse and keyboard input.

6.) Showing a dialogbox or writing text to the screen is a side effect.

7.) Math.max & Math.min

8.) When your program contains more then one statement, the statements are executed as if they are a story, left to right, top to bottom.

9.) A branchin road, where the program takes the proper branch based on the situation at hand.

10.) if - keyword

1 Like
  1. What is an expression?

An expression is the result of a fragment of code. More expressions together make a statement. Expressions alone just give back values that are not significant if not part of a greater context. Expressions are like words in a sentence.

  1. What is a binding?

A binding is statement that allows you to hold a value. Why we need that? Because this is how a machine, or a program, can remember a value.
It is composed of the keyword LET, the name of the binding and usually the value or the binding.
The keywords VAR and CONST can be used for bindings as well.

  1. What is an environment?

Is the collection of bindings and their values at a given time.

  1. What is a function?

A function is a piece of code, wrapped in a value that perform a specific task

  1. Give an example of a function.

alert(“This is a function”);

  1. What is a side effect?

A side effect is the result of invoking a function, such as, a dialog box or writing text to the screen. But functions produce values even without side effects, meaning merely giving back a value.

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

a) prompt(“Type your age”);

b) console.log(Math.math(2,4)); gives back a value

  1. What is control flow?

Statements are usually solved from top to bottom following an imaginary straight line. Control flow can also deviate from a straight line using IF and ELSE keywords.

  1. What is conditional execution?

Is the execution of a program using an alternative road.

IF , ELSE

1 Like
  1. An expression returns a value

  2. A pointer that is tied to value and can be disconnected and point to a new one.

  3. A group of binding and their values that exist at a certain time

  4. a line of code that is wrapped in a value

  5. the variable alert

  6. Is when a piece of code modify any state, ie. printing screen or reassign a variable.

  7. prompt(“hello”) has the side effect of outputting on the console

  8. the statements are executed from top to bottom. This is a straight-line control flow.

  9. Portions of code will run only if certain conditions are satisfied.

  10. if & else

1 Like

I have a question about the if-else questionnaire. I failed it but don’t understand why? there is no “if” declaration in the question only an "alert " as far as I know alert is like a console.log a “return” of its data in (). Am I missing something?

Could you elaborate more @bobchain, You meant to say you do not understand how if conditions are written?

1 Like
  1. an expression is code that produces a value.
  2. A binding (Variable) is a named piece of computer memory, containing some information inside
  3. An enviroment is set of variables and their values that exsist in memory at a given time.
  4. A function is named section of a program that performs a specific task.
  5. (alert).(“I am an argument”)
  6. Side effect is a statement result that affects the program &.is Nan() would produce a value, number() would produce a side effect by converting a value to number.
  7. Control flow is the way the program is executed. Javascript control flow is top to bottom like humans read a page.
  8. Let num =0
    const func =()=>{
    num = 1;
    return true;
    }
    func();
  9. if, if else, loop, True/false
1 Like

1.a piece of code that produces a value.
2.a binding (or variable) is a stored value given a name. for example let number10 = 10. the name number10 can be called later and will give the value 10.
3.the environment is the every current binding and it’s current value.
4.a piece of program “inside” a value. that way a specific piece of code can easily be called on repeatedly in different places/situations in the program. there are already many pre-existing functions.
5.prompt(“Password”);
6.a side effect is when a statement or function changes something outside of it’s own scope.
7. 1- prompt(“Password”);
2- console.log(15+5);
8. The order in which the statements are executed.
9.this is certain parts of the code will only be executed under certain circumstances.
10.if, if else, loop or true/false

1 Like
  1. An expression is a fragment of code that produces a value.
  2. A statement that uses a value while maintaining the internal state.
  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 is a function that writes out its arguments to a particular text output device.
  6. Changes in the internal state affecting statements that come after.
  7. a) Showing a dialog box or writing text to the screen is a side effect.
    b) the function Math.max takes any amount of number arguments and gives back the greatest.
  8. The direction, or order, in which statements are executed.
  9. Executing code only if certain conditions are held- may not necessarily be linear, or top-down.
  10. “if” with a Boolean Expression written after in parenthesis, followed by a statement to execute. Braces, “{ }”, should be used with multiple statements, which would be the norm, to form a “Block”.
1 Like

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

What is a binding?
A binding is used to catch and hold values. Also called a variable. The ‘let’ keyword indicates that this sentence is going to define a binding.

What is an environment?
The environment is the collection of all bindings and their associated values.

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.

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

What is a side effect?
A dialogue 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.
console.log(); This function has a side effect of showing whatever argument was put inside of that function.
var d=5+3; This function produces a value of 8.

What is control flow?
The control flow of a program is the order in which statements are executed, which is from top to bottom.

What is conditional execution?
Conditional execution lets you program several logic paths based on current value tests and assertions.

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

1 Like
  • What is an expression?
    A fragment of code that produces a value
  • What is a binding?
    Also known as a variable 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.
    f(x) = x+1
  • 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”) side effect is popup on screen. f(x)=x+1 --> f(1)=2
  • What is control flow?
    The control flow is the order in which the computer executes statements in a script.
  • What is conditional execution?
    It is created with the if keyword, we want some code to be executed if, and only if, a certain condition holds
  • What kind of keyword do you need to use to invoke conditional execution?
    if
1 Like

[quote=“ivan, post:1, topic:3069, full:true”]
Welcome to the discussion about the reading assignment about Binding, Functions and Control Flow.

Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

  1. What is an expression? Expression is a piece of code that becomes a value.

  2. What is a binding? Binding connects variable and its value

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

  4. What is a function? Function is a block of code designed to perform a particular task.

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

  6. What is a side effect?A side effect is any effect other than that return value.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    function plusWithSideEffects(x, y) { alert(“This is a side effect”); return x + y; }

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

  9. What is conditional execution? The decision when program takes based on the given condition

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

*Use if to specify a block of code to be executed, if a specified condition is true

  • Use else to specify a block of code to be executed, if the same condition is false
1 Like

what is an expression 1) a Expression is any valid set of Literals FX Variables, Operators, and Expressions that evaluates
to a single value.

what is binding
2) The Bind method allows an Object to borrow a method from another Object without making a copy of that method.

what is an environment
3)So a environment. So if i am running a program in a Windows environment. it means running a program on a computer that has the Windows operating system.

what is a function
4) a function is a type of procedure or routine. in some programs you get a value back and in some other programming languages it does not return a value

give a example of a function
5)int main() {
int set1[5] = {10, 20, 30, 40, 50};
int set2[5] = {101, 201, 301, 401, 501};
int i, max;

/* Process first set of numbers available in set1[] */
max = set1[0];
i = 1;
while( i < 5 ) {
if( max < set1[i] ) {
max = set1[i];
}
i = i + 1;
}

printf(“Max in first set = %d\n”, max );

what is a side effect
6) it modifies some state variable value(s) outside its local environment.

Give an example of a function that produces a side effect and another function that produces a value.
7)consloe.log(lol);

var lol = accounts [0];

what is control flow
8) control flow is a instruction or function call of an imperative program that are executed or evaluated.

What is conditional execution?
9) Conditional execution controls whether or not the core will execute an instruction.

  1. What kind of keyword do you need to use to invoke conditional execution?
    ummm i dont know sorry :cry:
1 Like
  1. An expression is a fragment of code that produces a value. That includes values that are written literally. Expressions can also include other expressions.
  2. Binding is a way of catching and holding values in Javascript so that these values can be used repeatedly without being lost. The book likens bindings to tentacles that can grasp values, and can also detach and reattach to others. :octopus:
  3. An environment is the combination of bindings and their values that exist at a given time.
  4. A function is a piece of program that is wrapped in a value.
  5. An example of a function would be console.log
  6. A side effect is something that happens as a result of executing a function that is besides the value it returns.
  7. A function that produces a side effect could be showing a dialog box or showing text on the screen. A function that produces a value could be something that compares or calculates numbers and then returns a value.
  8. Control flow is the series of actions that happen in a program with more than one statement.
  9. Conditional execution is an alternative to straight-line control flow where the program chooses from multiple branches of possible executions based on the situation.
  10. To invoke conditional execution, you need to use the keyword “if”.
1 Like
  1. Expression is a fragment of code that produces a value. Every value written literally (such as 99 or “angel”) 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. Expressions can contain other expressions, thereby allows building expressions that describe arbitrarily complex computations.

  2. A binding or variable is used to catch things and grab hold of a number, which value is produced by an operator and expression. Once a binding is defined, its name can be used as an expression, the value of which is the value the binding currently holds, as in:
    let ten = 10; console.log(ten * ten); // → 100
    A binding points at a value that may not have to be permanent and can be changed by using an operator at any time on existing bindings to disconnect them from their current value and have them point to a new one.
    let mood = “light”; console.log(mood); // → light
    mood = “dark”; console.log(mood); // → dark
    A statement may define multiple bindings, separated by commas.
    Binding names can be any word and have digits though they cannot start with a digit. A binding name may include dollar signs ($) or underscores (_) but no other punctuation or special characters.
    These keywords and reserved words may not be used as binding names:
    break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import interface in instanceof let new package private protected public return static super switch this throw true try typeof var void while with yield

  3. An environment is 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 that can be applied in order to run a wrapped program. 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. The values between the parentheses are given to the program inside the function.

  5. An example of a function is prompt function, which uses the string that we give it as the text to show in the dialog box: prompt(“Enter passcode”); Enter passcode

  6. A side effect is an application state change that is observable outside the called function besides returning a value.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log(Math.max(2, 4)); --> produce side effect: 4
    console.log(Math.min(2, 4) + 100); --> produce a value: 102
    [N.B. I am not sure about my answer to this question]

  8. Control flow is the order in which statements or instructions or functions are executed in a program script from the first line till the last line.

  9. Conditional execution controls whether or not the core will execute an instruction. Most instructions have a condition attribute that determines if the core will execute it based on the setting of the condition flags. In the simple case, some code will be executed if, and only if, a certain condition holds. Otherwise, the code or statement will be skipped.

  10. The kind of keyword used to invoke conditional execution is “if”. But if a condition does not hold true, you need another code to handle the other case and use the “else” keyword, together with if, to create two separate, alternative execution paths. And if you have more than two paths to choose from, you can “chain” multiple if/else pairs together.

1 Like