Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?
    A fragment of code that produces a value is called an expression
  2. What is a binding?
    A thing that catch and hold values
  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
  5. Give an example of a function.
    Alert(“Enter password hint”);
  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.
    prompt(“Enter DOB”);
    console.log(D+B); produces a value.
    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?
    Where the program do not take the straight road but instead 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. A fragment of code that produces a value is called an expression
  2. Binding is a variable that stores value so that we can use it at a later date
  3. An environment is a set of existing bindings
  4. A function is a segment of code/programme that is wrapped in a value.
  5. An example of a function is the prompt keyword that produces a dialogue box for the user to input. prompt(“what’s your name”);
  6. A side effect is the result of a piece of code that produces something for the user to see. For example a dialogue box or text
  7. a) prompt(“enter password”); b) console.log(Math.min(2,4) + 100);
  8. When your programme contains more than one statement, they are executed from top to bottom (in order they were written)
    9/10. Created with the if keyword, a conditional execution takes the proper branch/direction based on the situation that is presented
1 Like
  1. What is an expression? the value produced from a piece of code.
  2. What is a binding? it’s how javascript catches and assigns a value to a variable.
  3. What is an environment? a collection of bindings and their values.
  4. What is a function? a piece of program wrapped in a value.
  5. Give an example of a function. alert(“Hello friend!”);
  6. What is a side effect? any application state change that is observable outside the called function other than its return value.
  7. Give an example of a function that produces a side effect and another function that produces a value. side effect: function plusWithSideEffects(x, y) { alert(“This is a side effect”); return x + y; }. function that produces a value: function plus(x, y) { return x + y; }
  8. What is control flow? the order of our code and evaluation of statements.
  9. What is conditional execution? the code will be executed if certain conditions exist.
  10. What kind of keyword do you need to use to invoke conditional execution? IF
1 Like
  1. What is an expression?
    An expression is code that produces a value.
  2. What is a binding?
    A Binding is a special rule for a variable involving a key word to give direction to the binding. Consider the words DO and SOMETHING. DO is the special word. SOMETHING is the variable. Together they form a binding.
  3. What is an environment?
    An environment is the collection of bindings that exist at a given time.
  4. What is a function?
    A JavaScript function is a block of code designed to perform a particular task.

A function is a piece of a program wrapped in a value.
5. Give an example of a function.
alert(“This message is important”)
6. What is a side effect?
A Side effect is an observable change in the state of the application.
(So basically any function that changes the page visibly)
7. Give an example of a function that produces a side effect and another function that produces a value.
SIDE EFFECT: alert(“Hello World”) also prompt(“What is your name?”)
PRODUCES VALUE console.log(“Hello World”)
8. What is control flow?
Control flow is the ORDER in which a program will execute the code, starting from top to bottom.
9. What is conditional execution?
A point where the program decides what to do based on certain conditions.
10. What kind of keyword do you need to use to invoke conditional execution?
There are more than one but the word “if” is needed regardless.

1 Like
  1. Expression is a fragment of a code that produces a value.
  2. Binding are used to catch and hold values.
  3. The environment is a collection of bindings and their values.
  4. Function is a piece of program wrapped in values.
  5. prompt(“Enter anything”);
  6. Side effects are statements that affect the world.for example it can display something.
  7. console.log(value);alert(side effect);
  8. when you give more than 1 statement they are executed like a story, from top to bottom.
  9. It’s a branching road where a program takes the proper branch based on the situation at hand.
  10. if,else.
1 Like
  1. a fragment of code that produces a value
  2. a way to catch and hold values
  3. a collection of bindings and their values that exist at a given time
  4. part of a program wrapped in value
  5. prompt()
  6. a dialogue box or text on a screen
  7. prompt() produces a side effect. math.min produces a value
  8. when you program contains multiple statements, the statements are executed in story form.
1 Like
  1. Is a code that produces value.
  2. A binding is where you put value to a variable
  3. An environment is the collection of bindings and their values that exist at a given time.
  4. Function has an input and an output
  5. alert (“I’ll work hard everyday”)
  6. Modifying the state of the variables value
  7. var count = 1;
    function nonPureFunc(arg) {
    … count +=1;
    … console.log(arg);
    }

console.log(count);
1
undefined

nonPureFunc(‘hi’)
hi
undefined

count
2

  1. Control flow is a program that contains more than 1 statement.
  2. In conditional flow the program can choose between two boolean based values.
  3. If and else
1 Like

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

A javascript binding or also called “variable”, it’s the name that catch and holds a value.

Collection of bindings and their values that exist at a given time.

a piece of program wrapped in a value. So, you can use this value to run the wrapped program.

function circle(number) {
  return number * number;
};

Is when each time we call a function, we’re gonna get a different result.

function that produces a value:

function add(a, b) {
return a + b;
};

function that produces a side effect:

var x = 2;
var y = 5;

var add = () => ( x + y ) {
return add();
};

Is the order in which the computer executes statements in a script. It goes from top to bottom.

The program can have more than one road to get the result, so a conditional execution is when the program takes the proper branch according to the situation at that moment.

" If" When we want to execute something if and only if, conditions fullfill.

1 Like

What is an expression?

A piece of code that produces a value. Every value written is an expression.

What is a binding?

When using binding the a value is held in a chosen variable to be accessed at anytime in your program as an expression.

What is an environment?

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

What is a function?

A small program that performs a specific job and produces a value based on a variable input.

Give an example of a function.

Binding prompt

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.

Dialog box produces side effect

The Math.max function provides the return of the greatest number in a list of numbers

What is control flow?

The order of operation in which commands are executed.

What is conditional execution?

A piece of code that is only executed if a set of prerequisite requirements or values have been reached.

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

IF statement

1 Like
  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:

  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 definition is a regular binding where the value of the binding is a function.

  5. Give an example of a function.

    alert (“This is Ivan on Tech Acadamy”);

  6. What is a side effect?

    A side effect is a function which produces an expression and returns that value. it
    prints a line

  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?

    To create a branching road, where the program takes the proper branch based on
    the situation at hand. This is called conditional execution.

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

    Conditional execution is created with the if in JavaScript.

1 Like
  • What is an expression?

    An expression is where a code results in a value. basically this can be anything such as a number or text.

  • What is a binding?

    Binding is where something is grabbed for use. For example Let is a binding as it establishes something that is for use in a statement… all bindings much have a value otherwise there is no use for it. It is like having a fishing rod with no line.

  • What is an environment?

An environment is a collection of bindings and their values. One cooulpd have three bindings each with their vaslues and collectively that woupd be an, ‘environment.’

  • What is a function?

  • Give an example of a function.

    A function is the performance of something. It is where something is ordered to be done and what is to be done. Such as a prompt for example. Which orders that something should be done such as an entry of some sort into a box or field.

  • What is a side effect?

    A side effect is that which results from doing something else. Side effects are sometimes the purpose of the action even though they are essentially side effects.

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

Setting up a dialogue box produces the side effect of an actual box displayed which can be filled with an expression.

A function that does not produce a side effect could be a mathematical calculation that simply demands a result.

  • What is control flow?

    Control flow is that sequence of actions that result in a given result.

  • What is conditional execution?

    a conditional execution is where a choice can be made, such as ‘or’ or ‘if’’ in an instruction.

    If this then that for example. or this or that. It offers a different flow to the execution of the command by giving a choice depending on data supplied.

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

    ‘Or’, ‘If’, would be common conditional key words one could use.

1 Like
  1. What is an expression?
  2. What is a binding?
  3. What is an environment?
  4. What is a function?
  5. Give an example of a function.
  6. What is a side effect?
  7. Give an example of a function that produces a side effect and another function that produces a value.
  8. What is control flow?
  9. What is conditional execution?
  10. What kind of keyword do you need to use to invoke conditional execution?
  1. An expression is any piece of code represents values.
  2. binding is a relation between a variable and a value.
  3. An environment is “the collection of bindings and their values that exist at a given time”. Like something that allows us to interact with the surrounding system(keyboard, mouse, etc)
  4. Function is a piece of program wrapped in a value. The value can be called to run the wrapped program.
  5. console.log("***")
  6. If a statement or function can modify the values or state of something, it is called side effect.
  7. prompt or console.log
  8. Control flow is the sequence of the code are run in the system.
  9. Conditional excecution means that some part of the code is goingn to be executed only if certain condition is met.
  10. e.g. “if”, “while”, “?”, etc
1 Like
  1. An Expression is a fragment of a code that produces or holds a value. Expressions can contain other Expressions.
  2. Binding is another name for a variable. It means a value is tied to a certain binding name (which then turns into an expression). However , it is not tied to it forever unless it is a constant.
  3. The collection of values that exist at a given time.
  4. A function is a constant binding that executes a certain task and
    produces a value or a side effect.
  5. console.log(Math.max(2, 4));
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Side effect: alert(“Hello world”)
    Value: console.log(“Hello world”)
  8. Control flow is the order in which statements, functions and expressions in general are executed. From top to bottom.
  9. That is the execution of a code only if the value of the boolean expressions from the previous condition is positiv.
  10. IF
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 a statement that creates a store for values.

What is an environment?

The environment is the entirety of all bindings and their respective values.

What is a function?

Functions are blocks of code that can be named and reused. They consist of statements designated to accomplish a specific task.

Give an example of a function.

function addTwoNumbers(x, y) {

return x + y;

}

What is a side effect?

Functions with side effects do something other than returning a value (though they may do that as well).

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

Without side effect: function plus(x, y) { return x + y; }

With side effect: function plusWithSideEffects(x, y) { alert(“This is a side effect”); return x + y; }

What is control flow?

The control flow defines the order in which the program statements are executed.

What is conditional execution?

Conditional execution means that some part of a program is only executed depending on a condition.

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

if

1 Like

Binding, Functions and Control Flow - Reading Assignment

  1. What is an expression?
    A piece of code that produces a value is called an expression. An expression between parentheses is also an expression.

  2. What is a binding?
    () The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called. Link to a value.

  3. What is an environment?
    The collection of variables 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 and usually this piece of program will perform something useful - this will be invoked using the function value that contains it.

  5. Give an example of a function.
    print(“X”);
    prompt(“Provide your current age.”);

  6. What is a side effect?
    If expression can print information on the screen, for example, that will count as changing the world. Or, it could change the internal state of the program in some way that will affect statements following after its execution.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    for a side effect function --> alert(“Hello”); produces a window on the screen
    value producing function -->
    console.log(Math.min(3, 6) + 225);
    228

  8. What is control flow?
    Control flow is the way program with more than one statement gets executed - from top to bottom!

  9. What is conditional execution?
    It will execute program in order we pre-set it to follow. We use keyword ‘if’ in combination with condition expressions to write this according to our needs.

  10. What kind of keyword do you need to use to invoke conditional execution?
    ‘if’ and in ‘else’ to create two separate paths.

G.

1 Like
  1. What is an expression?
    is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.
    2.What is a binding?
    Is associating an identifier to whatever it identifies, be it a method, a variable or a type.

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

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

5.Give an example of a function.
Alert " Time has expired"

6.What is a side effect?
Is a showing of a dialog box.

7.Give an example of a function that produces a side effect and another function that produces a value.
Prompt("Today date is’)
value example
console.log(math.max(2,4))
4
8.What is control flow?
is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated.

9.What is conditional execution?
An action in which condition is executed only if it meets predefined condition.

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

1 Like
  1. What is an expression?
    A fragment of code that produces a value is called an expression. It is the simplest kind of statement with a semicolon after it

  2. What is a binding?
    A variable used by a statement to catch and hold values

  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

  5. Give an example of a function.
    Prompt function in a browser environment

  6. What is a side effect?
    A change caused by a statement that counts as changing the world or changing the internal state of the given computing machine.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Prompt function gives a side effect
    Math.max function gives a value

  8. What is control flow?
    The orderly execution of statements, contained in a program, from the top statement to the bottom statement.

  9. What is conditional execution?
    The orderly execution of only statements that satisfy respective conditions, contained in a program, from the top statement to the bottom statement.

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

1 Like

1. What is an expression?

It is a fragment of code that produces a value. An expression is like a sentence fragment whilst a statement is more like a full sentence. A program is a list of statements and the simplest kind of statement is an expression with a semicolon after it. For example true;

2. What is a binding?

Bindings are used to catch and hold values. In the example

const price = 10;

the const keyword tells us that the sentence will contain a binding. The statement creates a binding named “price.” And the equal (=) operator gives us a value of 10. After the binding (named “price”) has been created its name can be used as an expression.

3. What is an 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.

5. Give an example of a function.

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

6. What is a side effect?

Some functions are called for their return value, some are called for their “side effects,” and some are called for both. A pure function produces a value with no side effects, nor does it rely on side effects. A side effect can be useful though. It can do things like can log to the console or write 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 welcomeName(name) {
  console.log("Welcome " + name);
}

// value
function areaRectangle(length, width) {
 return length * width;
}

8. What is control flow?

The order of execution in a program. For programs with more than one statement, the statements are executed from top to bottom.

9. What is conditional execution?

If there is a fork in the road, certain conditions can dictate which path the program takes. We may only want a piece of code to be executed when a certain condition exists.

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

The keyword “if”. It’s used as, “if this, then that.” We see it used in “if-else” statements.

1 Like

1 An expression is every value you can use in a program. E.g. the string “hello”, the number 3579 and so on.

2 With a binding you can “hold” a value, but also a function for example. I liked very much the idea of the author to imagine bindings as an octopus who grabs a value.

3 An environment is defined by the bindings already defined, for example when you start a program. The environment can not be empty, since in every programming languages already exists a bunch of predefined bindings.

4 & 5 A piece of program wrapped in a value. Functions can have a side effect (eg. show a browser dialog window) or give back a value. You can wrap a function into a function into a function… An example for a function in a function is console.log(Math.max(3,54353)); - console.log is a function, and also math.max.

6 A side effect does change the “world”, for example writing to a database, printing an output on the screen,…

7 Function that produces a side effect:
userinput=prompt((“give me a number”));
if (!isNaN(userinput)) {
console.log(“ok that’s a number, you’ve chosen”, userinput);
};

Function that produces a value:
let sidea=2, sideb=3;
sqareareacalculator=sidea*sideb;

8 Control flow is a linear execution of 2 or more statements, exactly in the way you would read the lines, from top to bottom.

9 A conditional execution is not linear, but depends - as the name says - on conditions. Depending on for example the value of a user input, the program will behave in a different way.

10 For calling a conditional execution we use the keyword “if”.

1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is a way for javascript to catch and store values.
  3. An environment is a collection of bindings and their values that exist at one time.
  4. A function is a piece of program wrapped in a value, where the value can be applied to run the wrapped program.
  5. Console.log is a function that can be used to output values.
  6. A side effect is an observable change that occurs from a functions output, other than its return value
  7. An example of a function that produces a side effect is the alert function; An example of a function that produces a value is Math.max or Math.min.
  8. Control Flow is the order in which the statements are executed.
  9. Conditional Execution is the execution of a statement if and only if the pre-determined conditions set are met.
  10. " If " is used to invoke conditional execution.
1 Like