Binding, Functions and Control Flow - Reading Assignment

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

2. What is a binding?
Binding is that can hold values in JS.

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

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

5. Give an example of a function.
promt(“Enter a number”);
When prompt is the function that print a text box on screen and request for a value.
Enter a number is the argument of the function.

6. What is a side effect?
A side effect is a change made by a statement in JS. It can be displaying something on screen or changing the internal state of the machine.

7. Give an example of a function that produces a side effect and another function that produces a value.
1 - alert(“Hello world”) is a function producing a side effect.
2 - Math.max(3,2); is a function producing a value. In this case, the value is 3

8. What is control flow?
It is the order in executing the function in a program.

9. What is conditional execution?
Conditional execution is the process that may takes more than one path from the input to the output.

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

What is an expression?
Fragment of code, runs and produces a value
What is a binding?
a binding graps values to have access and affect them
What is an environment?
collection of bindings and their values that exist at a given time
What is a function?
A function is a fragment of code that runs and produces a value
What is a side effect?
a side effect changes results from a statement.
Give an example of a function that produces a side effect and another function that produces a value.
// produce a side effect…
console.log(“hey everybody”)
// Produce a value…
var multiplikation = 2*2;
console.log("The answer is: ", multiplication);
What is control flow?
Control flow orders in wich programm executes.
What is conditional execution?
conditional execution, uses operators to determine if a function can execute is if or while, or case statements.
What kind of keyword do you need to use to invoke conditional execution?
if function to invoke conditional execution.

  • What is an expression?
    Any code that prduces a value.

  • What is a binding?
    Is pointing a value to a variable

  • What is an environment?
    Is the set of values that point to the variables or bindings at a certain point in runtime.

  • What is a function?
    A group of statements that may be called at any moment and be used repeatedly. They may give back a value or not.

  • Give an example of a function.
    typeOf (“Hello world”);

  • What is a side effect?
    Any change that a code makes to the world. Like an internal value, a printout to the screen, printer or make a sound.

  • Give an example of a function that produces a side effect and another function that produces a value.
    SideEffect alert(“hello world”);
    Value Let a=1;

  • What is control flow?
    Is the order in which the code will be executed. JS works Top-to-bottom.

  • What is conditional execution?
    Is a device that will direct the flow of a program when certain conditions are met.

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

  1. An expression is a fragment of code that gives us a value
  2. A binding is a tool helping us to catch a value
  3. An environment is the aggregate of the values and the bindings
  4. A function is a piece of program wrapped in a value
  5. prompt is a function
  6. A side effect is something showing on the user’s screen
  7. prompt function gives us a side effect and the return function gives us a value
  8. Control flow is the way the programm is executed
  9. Conditional execution is a tool helping us to allow different paths depending on the validation of the condition
  10. We need to use “If”
  1. Fragment of code
  2. A variable that catches and holds a value and can let it go
  3. Collection of bindings and their values that exist at a given time
  4. Piece of program in a value
  5. math.max
  6. Statements that stand alone and effect other statements
  7. console.log and math.max
  8. When program contains more than one statement the statements are executed as if they are a story from top to bottom
  9. The program takes the proper branch based on the situation at hand
  10. If

1.Ans. A fragment of code that produces a value.
2.Ans. A function or keyword to catch and hold value.
3.Ans.The collection of bindings and their values that exist at a given time.
4.Ans.Function is a piece of program wrapped in a Value.
5.Ans. Prompt(“Enter passcode”);
6.Ans. Showing a dialog box or writing text to the screen is a side effect.’
7.Ans Console.log(Math.max(2,4,));//->4 and Math.Min(2,40+100);//->102
8.Ans.When your program contains more than one statement,the statement as if they
are a story, from top to bottom.
9.Ans A branching road where the program takes the proper branch based on the situation at
hand.
10.Ans. if you may also use else

What is an expression?
fragment of code that produces a value
What is a binding?
An assignment of value
What is an environment?
the set of bindings and their values at a particular time
What is a function?
Fragment of code that outputs a value
Give an example of a function.
Max(4,2) -> 4
What is a side effect?
a change to the environment an expression accomplishes
Give an example of a function that produces a side effect and another function that produces a value.
(i.e 1+1; has no side effect but produces the value 2. x=1+1; assigns value to x, even if x is never used again. These are really just expressions, but you get it.)
What is control flow?
The order of operations in the execution of a program or function
What is conditional execution?
A portion of code that only executes when a specific condition is met.
What kind of keyword do you need to use to invoke conditional execution?
if then else while for

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

  2. Binding or variable is used to catch and hold values.

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

  4. Function is a piece of program wrapped in a value

  5. Console.log(), if(), sum(), math.max().

  6. Side effect is produced by funcions. It could be dialog box or text on the screen.

  7. Side effect example:
    public class SideEffectClass{

    private int state = 0;

    public doSomething(int arg0){
    state += arg0;
    }
    }

Value example:
console.log(Math.max(2, 4));
// → 4
8. Control flow is when program executes particular blocks of code.
9. Conditional execution is when program executes the code trough created branching road which is based by situation at branch.
10. If and Else.

  1. An expression is a fragment of a code that produces a value.
  2. Binding, in JS, lets you catch and hold values.
  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. console.log();
  6. A side effect could be dialog box or writing text;
  7. value: math.min();
    side effect: prompt();
  8. The way in which the statements are executed
  9. The statements are executed if certain conditions are met.
  10. if

What is an expression?
An expression is when a fragment of code produces a value.

What is a binding?
Binding is when you catch and hold values to a variable.

What is an environment?
the collecion of values and varibles that exist within a certain time

What is a function?
Function is a piece of program wrapped within a value

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

What is a side effect?
When a dialog box or writing text is delivered to the screen, these are a side effect of the value given by the prompt.

Give an example of a function that produces a side effect and another function that produces a value.
1: prompt(“Enter passcode”);
2: console.log(Math.min(2, 4) + 100);

What is control flow?
When a program contains more than one statement it reads it like a story, from top to bottom.

What is conditional execution?
When we branch the string in a unconviential flow to brake the order of statements. We use this using the IF tool.

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

  1. An expression is a snippet of code that produces a value or primitive

  2. A binding is referred to as a variable… grabs hold of something or remembers it to be used again. defined as let, var, const.

  3. An environment is a set of bindings and values that exist in a given time. It provides ways for program to interact with the surrounding system.

  4. A function is a piece of program wrapped in a value which can be called to run the “wrapped” program.

  5. One example of a function is the COUNT function

  6. A side effect is the result of a function other than its intended “value”. Example could be text on a screen or a dialog box

  7. A function that produces a side effect would be “console.log()” and one that produces a value would be the math.sqrt() function because it simply produces a value based on the argument in the function.

  8. Control flow is the flow of statements in a program that only makes sense with the result of the previous statement. Such as converting a number given in string to an actual number.

  9. Conditional execution is where a program relies on a decision based on the input given to it as in the case of an If/else statement

  10. the if keyword

What is an expression?

  • a piece of code that produces a value
    What is a binding?
  • it captures and holds a value (also known as a ‘variable’)
    What is an environment?
  • this is the state of bindings and their variables at any given time
    What is a function?
  • a function is a block of code stored for later use and may return a value (can be an ‘object’ with both properties and methods)
    Give an example of a function.
  • prompt();
    What is a side effect?
  • eg throwing up a ‘hassle screen’ or writing some text or garble to the screen
    Give an example of a function that produces a side effect and another function that produces a value.
  • prompt() gives a side effect and Math.max() gives a value
    What is control flow?
  • when the program contains more than one statement executed sequentially
    What is conditional execution?
  • it is executed if a certain condition is met (such as in an “if” statement)
    What kind of keyword do you need to use to invoke conditional execution?
  • ‘if’ or ‘while’

What is an expression?
Ans: Anything that produces a value is an expression in JavaScript
What is a binding?
Ans: To catch and hold values, JavaScript provides a thing called a binding
What is an environment?
Ans: The collection of bindings and their values that exist at a given time is called the environment.
What is a function?
Ans: A function is a piece of program wrapped in a value.
Give an example of a function.
Ans: Below function can be used to add two numbers ‘a’ and ‘b’

def addNumbers(a,b){
return a+b;
}

What is a side effect?
Ans: Showing a dialog box or writing text to the screen is a side effect. A lot of functions are useful because of the side effects they produce. Functions may also produce values, in which case they don’t need to have a side effect to be useful. For example, the function Math.max takes any amount of number arguments and gives back the greatest. Give an example of a function that produces a side effect and another function that produces a value.
What is control flow?
Ans: When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. Simple example is various expressions getting executed one after the other.
What is conditional execution?
Ans: 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);
}

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

  1. What is an expression?
    Expression is a set of numbers or variables separated with operators indicating what operations and in what order need to be executed to get a result

  2. What is a binding?
    A binding binds a variable with the value, expression or object

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

  4. What is a function?
    Function is a fragment of program which returns a value

  5. Give an example of a function.
    fnAdd(a, b) { return a + b; }

  6. What is a side effect?
    Side effect is for example showing a message box or writing the text to the screen

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect function: alert(“Hello world”);
    Value function: fnAdd(a, b) { return a + b; }

  8. What is control flow?
    Is the rule the program is executed - from top to bottom

  9. What is conditional execution?
    It is when in order the fragment of code to be executed the condition must be true

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

  • What is an expression?
    An expression is a combination of values and operators that create a new value.

  • What is a binding?
    Its basically a variable. It does not contain any values but rather refer(grasp) to values. Its used when you need to remember a value.

  • What is an environment?
    Its the current count of bindings and their values at the time.

  • What is a function?
    A function is basically a program wrapped in a value. You can say it is reusable code. You create a function once and then you can always invoke it at any time later on.

  • Give an example of a function.
    consol.log is a function in javascript.

    example on how a function can look like:
    function functionNAME (a, b) {
    return a* b;
    }

    this function when called on is returning the sum of multiplying the 2 arguments you give it.

  • What is a side effect?
    A side effect is when a statement is causing some observable effect outside the immediate context of code. Example changing a pixel on your computer screen or changing the internal components inside you code thats going to affect the rest of the statements going forward.

  • Give an example of a function that produces a side effect and another function that produces a value.
    consol.log produces a side effect and Math.max just produces a value.

    example of how simple programs for both could look like:

    var x = “Test”
    function sideeffect () {
    return x = “TestModd”
    }

    If the variable x now is in another statement or function thats going to change how they executes most likely and with that we have a sideeffect.

    function value (a, b) {
    return a+b
    }

    This is going to just give back a value.

  • What is control flow?
    Its about which order the program execute different codes. Its executes from top to bottom.

  • What is conditional execution?
    When you want to execute some code only if a condition is met otherwise do something else.

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

  1. What is an expression? - A fragment of code that produces a value.
  2. What is a binding? - used to catch and hold values. Also called a variable. The ‘let’ keyword indicates that this sentence is going to define a binding.
  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. - The consol.log is a function.
  6. What is a side effect? - A statement that changes 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 example: console.log(Math.min(5, 25)); a function that produces a value (or return) is consol.log(Math.max(5,25) + 100);
  8. What is control flow? - the order in which statements are performed, from top to bottom
  9. What is conditional execution? - created with the keyword ‘if’ and used if a branching road is wanted where the program takes a different path based on the situation.
  10. What kind of keyword do you need to use to invoke conditional execution? - The keyword ‘if’ invokes a conditional execution
  1. What is an expression?
    An expression is a fragment or pieces of code that produces a value. All values that are written literally are also expressions.
  2. What is a binding?
    A binding is the catching and holding of a value. Particularly when a new value is created because if the new value not used immediately it will dissipate again. Binding is done in the form of a variable (var). bindings are like tentacles that grasp onto the value.
  3. What is an environment?
    The environment is a collection and group of binding and values at a given time.
  4. What is a function?
    A function is a piece of program that is wrapped in a value
  5. Give an example of a function.
    alert(“I am rightious”)
  6. What is a side effect?
    When the screen displays a dialog box or written text that could change the internal state of the machine that will cause change in the statement that comes afterwards
  7. Give an example of a function that produces a side effect and another function that produces a value.
    let num = 0;
    const func = () => {
    num = 1;
    return true;
    }
    func();
  8. What is control flow?
    When the program has more than one statement creating a story from top to bottom as they are executed.
  9. What is conditional execution?
    Where the program wants to create a branching road based on the situation at hand
  10. What kind of keyword do you need to use to invoke conditional execution?
    A conditional execution is created with the IF keyword.
  1. Expression is a piece of code that produces some value.
  2. A binding is handle to some value or data.
  3. Environment is the set of available bindings at any time.
  4. Function is a segment of program that can be run independently by calling it from any point in a program.
  5. console.log() , alert(), prompt()
  6. Side effects are the changes that are made to the machine state in consequence of running any program or any segment of it.
  7. Side effect function:

var a=2;
function sideEffect(_a){
     a=_a;
}
x(3);
function valueProduce(){
     return 5;
}
a=valueProduce();

  1. Control Flow is the sequence of execution in a program.
  2. When some code segment is executed based on the satisfaction of some condition.
  3. If, else
  1. Anything in the code with a value is classed as an expression, numbers, strings etc
  2. A binding contains and catches the information, pointing to certain values
  3. A cluster or collection of bindings which represent values
  4. The function is a set task and a product of values performing an instructed task
  5. alert(5+(10*10));
  6. a pop up box or writing into a opt in form, changing and effecting the program
  7. alert(welcome to england);
  8. the sequence in which a set of statements are executed by a program
  9. alternate sequences being executed by the user’s input
  10. if,else

What is an expression?
A fragment of code that produces a value is called expression. Expressions can contain other expressions in a way similar to how sub-sentences in human languages are nested.

What is a binding?
Binding refers to a procedure where values are caught and held, so that they are kept internally.

What is an environment?
An environment refers to 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
Console.log

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. A lot of functions are useful because of the side effects they produce.

Give an example of a function that produces a side effect and another function that produces a value
Function that produces a side effect
prompt(“Enter your name”);
Function that produces a value
console.log(Math.max(2, 4));

What is control flow?
Control flow refers to the order in which statements are executed. They are executed from top to bottom.

What is conditional execution?
Conditional execution is when programs are coded to take proper branch based on the situation at hand.

What kind of keyword do you need to use to invoke conditional execution?
Conditional execution is created with the “if” keyword in JavaScript. Under this function, the code will only be executed if and only if a certain condition holds.

You can also use “else” keyword, together with if, to create two separate, alternative execution paths.