Binding, Functions and Control Flow - Reading Assignment

  1. An expression is a fragment of code that produces a value
  2. A binding is the vaule attached to the phrase.
    3.The collection of bindings and their values that exist at a given time is called the environment.
    4.A function is a set of statements that performs a task or calculates a value.
    5.prompt(“Enter passcode”);
    6.When a function effects something other that itself it is a side effect.
    7.a.prompt(“Enter passcode”);
    b.let 1=15
    console.log1;
    8.Control flow is the order in which we code and have our statements evaluated.
    9.Conditional execution certain parts of the code are only executed if a certain condition is fulfilled and is defined with if
    10.If
  1. An expression is fragment of code that produces a value.

  2. The binding () method creates new function that, when called, has it’s This keyword set to the provided value with a given sequence of arguments preceding any provided when the new function is called.

  3. The environment is a collection of bindings & their values that exist at a given time.

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

  5. A function is a piece of program wrapped in a value, Such values can be applied in order to run the wrapped program. An example of this is when a browser ask it’s user for the password.

  6. An expression can be content to just produce a value, which can then be used by the enclosed code. A statement stands on it’s own, so it amounts to something only if it affects the world. It could display something on the screen- that counts as changing the world- or it change the internal state of the machine in a way that affects the statements that come after it these changes are called side affects.

  7. Showing a dialog box or writing text to the screen is a side effect.

  8. Control flow statements are those that make decisions about what happens in a program. A programmer needs to take care that the conditions used do not contradict one another. This would create regions in the code that would be unreachable.

  9. Conditional executions is the ability to execute a piece of code depending on some condition.

  10. The if keyword executes or skips a statement depending on the value of a Boolean expression.

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

  2. To catch and hold values, JavaScript provides a thing called a
    binding, or variable:
    let caught = 5 * 5;
    That’s a second kind of statement. The special word (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.

  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. Such values can be applied
    in order to run the wrapped program.

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

  7. For example, the function Math.max takes any amount of number
    arguments and gives back the greatest.
    console.log(Math.max(2, 4));
    // → 4
    and one that producees a value:
    console.log(Math.min(2, 4) + 100);
    // → 102
    (not sure i’m right now) already find it difficult to understand this, but i keep on going :wink:

  8. When your program contains more than one statement, the statements are executed as if they are a story and this is control flow. straight-line control flow.

  9. 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. If or else

1 Like

This stuff can get confusing at times, but you’ll get there the more you work with it.

On number 7 the examples of functions that return values vs those that perform some side effect.
Both of your examples contain both scenarios.

//This funtion call will not return a defined value that could be assigned to a binding
console.log("When this prints to the console, that is a side effect");
let a = Math.min(2,4); //this functions returns a value that we can assign to a binding.

function someDefinition() {
    //A functions that returns a value has a return statement
    return "Some Value";
}

//functions that don't have return statements perform side effects
function anotherDefinition( string parameter ) {
    console.log(parameter);
}

I hope this is helpful

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

  2. A binding is a piece of code that attaches a chosen word to a value.

  3. The environment is the collection of all bindings and their values at a given moment.

  4. A function is a piece of program that acts on a value

  5. prompt()

  6. A visual change in the state of the application.

  7. A function that produces a side effect : alert()
    A function that produces a value: console.log()

  8. Control flow is the order in which a programming language executes code. This issue from top to bottom.

  9. A conditional execution is when a piece of code is only executed when certain conditions are met.

  10. IF statement

  1. What is an expression?
    This is a fragment of code that produces a value.
  2. What is a binding?
    A special keyword, such as ‘let’ or ‘var’ that catches, hold values, and defines 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 programming wrapped in a value.
  5. Give an example of a function.
    var x = function (a,b) {return a*b};
    var z = x(4,3);
  6. What is a side effect?
    It is a change in value in a function. Looking at the example below, the side effect happens at “i++”. What happens here is “j” becomes “1” and then “i” gets incremented and becomes “2”. In short, two things happened and the side effect was that “i” became “2”.
    var I = 1;
    var j = i++;
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Example of a function that produces a “value” (product of two numbers) NOTE: the input and answer will always be the same:
    var x = myFunction(4,3);
    function myFunction(a,b) {
    return a*b;
    {
    //The result will be 12
    Example of a function that produces a side-effect:
    var I = 1;
    var j = i++;
  8. What is control flow?
    This is the order in which the computer executes statements in a script.
  9. What is conditional execution?
    The simplest explanation is using a Boolean expression that evaluates to “true”, then a code should be executed. For “false” the code is not executed. for example:
    //if the time on your browser in less than 10, you will get a “Take a Break” statement. NOTE: the code here will execute if the code is true. In this case, “Take a Break” will only execute if the time is less than 10.

//The next example will show how to execute some code if a condition is true and another code if a condition is false, by using the “if…else” statement.
//if the time on the browser is less than 10, the code will execute, “Take a Break”. Otherwise, you will get a “Time to Take Lunch “notification.

  1. What kind of keyword do you need to use to invoke conditional execution?
    “if/else”

1.What is a expression?
An expression is any fragment of code that gives us a value.

2.What is a binding?
A binding “grabs” or connects a keyword with a certain variable.

3.What is an environment?
The environment is the space in which the bindings and their values exist and interact. For example, certain variables can only work or exist only within certain functions. That is that variable’s particular environment. The entire code is known as a global environment.

4.What is a function?
A function is made up of expression(s) that produces/modifies a certain value.

5.Give an example of a function
A simple function can be something like

function sum(number1, number2){
return number1 + number2;
}

where we input two numbers, and the function changes the two numbers to produce a new result, which is the sum of both numbers.

  1. What is a side effect?
    A side effect is when a statement or function changes the state of a part of the code outside of its own scope.

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

let num = 0;
function new(number){
num = number;
}

Here, we can see that the function changes the variable num, even though the variable num is outside the scope of the function.

8.What is control flow?
Control flow means that order matters. How we placed our lines of code will affect the outcome.

9.What is conditional execution?
A conditional execution is a function that will execute one set of code if its argument is a certain value, and another set of code if the input argument is different. Some examples are the if-else statements or the ternary conditional operator.

10.What kind of keyword do you need to use to invoke conditional execution?
To invoke conditional execution, we can use the keywords “if”, “else” and “else if”.

1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is a variable.
  3. An environment is the collection of bindings and their values.
  4. A function is a piece of program wrapped in a value. (Doesn’t it make more sense to say “a value wrapped in a piece of program”?)
  5. An example of a function would be: console.log
  6. A side effect is the result produced by a function.
  7. “prompt” is a function that produces a side effect, “console.log” produces a value.
  8. Control flow is when the statements in a program are executed from top to bottom.
  9. Conditional execution is when the code is executed only if a certain condition is met.
  10. We use “if”.
  1. An expression is a fragment of code that produces a value.
  2. Bindings a.k.a. variables, catches and saves values in JavaScript programming.
  3. The environment houses an existing collection of bindings and their values within the surrounding system.
  4. A function is a section of program wrapped in a value. Use invoking, calling or applying to execute a function.
  5. A function for example, can be a dialog box asking for an email address or password.
  6. When using a function, the shown text or dialog box on the screen, asking for user input, is called a side effect.
  7. Side effect example-
    function myFunction() {
    var txt;
    var person = prompt(“Please enter your name:”, “Grey Hedge”);
    if (person == null || person == “”) {
    txt = “User cancelled the prompt.”;
    } else {
    txt = "Hello " + person + “! How are you today?”;
    }

Value examples-

console.log (Math.max (6,10));

10
-Or_
console.log (Math.min (82, 7) + 54);

61
8. Control flow results in a chosen order being made as to which of two or more functions, statements or instructions to follow is determined.
9. Conditional execution is a program that chooses the proper branch based on a particular situation.
10. If is the keyword to use for invoking a conditional execution.

What is an expression?
every value that is written literally such as 22 or “gumshield” is an expression, there are simple statements and there are statements that have side effects

What is a binding?
binding is used to catch and hold values, simply place let then then name of the binding and then you can give it a value e.g let shoe = “black”

What is an environment?
The collection of binding that exists at any given time is called the environment. Every web page will have bindings that contain functions such as how to interact with a mouse click and keyboard typing

What is a function?
a function is a piece of program wrapped in a value. such values can be applied in order to run a program. executing a function is called invoking, calling or applying it.

Give an example of a function.
prompt(“enter passwor”);

What is a side effect?
the result of a function is its side effect, if it changes something in the real world or in a machine. the text box that appears when you use the prompt function is an example of a side effect

Give an example of a function that produces a side effect and another function that produces a value.
prompt(“what is your name”); this will produce a side effect of a dialogue box
!false will give you a value of true

What is control flow?
_this is a function with more than one statement. the statements are exectuted from top to bottom _

What is conditional execution?
when you add an if statement to a function so that the second part is only executed under a certain condition passes

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

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

  2. What is a binding?
    A binding or variable is part or a peice of code that allows to catch and hold values in Javascript.

  3. What is an environment?
    An enviroment is a collection of bindings and their values that exist at a given time and provides ways to interact with the surrounding system.

  4. What is a function?
    A function is a peice of program wrapped within a value.

  5. Give an example of a function.
    prompt(“Enter passcode”); has the side effect of a prompting dialogue box.

  6. 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. Side effects include: Modifying any external variable or object property.

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

  8. What is control flow?
    When statements are excecuted after each other from top to bottom.

  9. What is conditional execution?
    A condition excecution is when their is code written as a branching road where the program can execute the command only if a certain condition holds.

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

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

What is a binding?
When a keyword or name grasps a value.

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 function is a piece of program wrapped in a value.

Give an example of a function.

Let num = (“why”);
Let letr = (“where”);
Console.log(num + letr);

What is a side effect?
A side effect is when a function or a statement makes a change to something outside of its own scope or changes the thereafter comin functions.

Give an example of a function that produces a side effect and another function that produces a value.
alert(hello world);
console.log(2+4);

What is control flow?
When your function contains more than one statement and it reads like a book going from left to right and top to bottom.

What is conditional execution?
Where the program takes the proper path or branch based on the situation at hand when there are multiple options the function can take.

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

1.) An expression is a fragment of a code producing a value
2.) A binding or variable grabs a value, which can be used as an expression (only for the first time “let” has to be used in front of the name)
3.) An environment is the collection of bindings and their values
4.) A piece of program wrapped in a value and thus the latter can be applied or called to execute a program.
5.) A password (to be provided in order to start the program)
6.) Changes that affect the following statements
7.) While showing a dialogue box produces side effects, math.max produces a value
8.) The order of execution in case of multiple statements.
9.) An execution, which depends on a particular condition to be met.
10.) “if” (and also “else”).

  1. A fragment of code that produces a value is called an expression. Every value
    that is written literally (such as 22 or “psychoanalysis”) 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.
  2. binding is a feature in JS that allows the coder to catch and hold values, without the concern that it will dissipate.
  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. Such values can be applied
    in order to run the wrapped program.
  5. prompt(“Enter passcode”);
  6. changes in the internal state of the machine in a way that will affect the statements that
    come after it. These changes are called side effects.
  7. prompt(“Enter passcode”);
    Math.max(2, 4);
  8. When a program contains more than one statement, the statements are
    executed as if they are a story, from top to bottom. Therefore, Control Flow is the flow of the execution of commands: top to bottom and left to right, except where exists parenthesis.
  9. Conditional executions are forks on the Control Flow that occur whenever there is a IF statement, in such a way: if “this happens” then “do that”
  10. the function IF
1 Like

1 A fragment of code that produces a value

2 Binding is what the name suggests, it binds to values. It can be changed afterwards.

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

4 A piece of program wrapped in a value.

5 prompt(“Enter passcode”); console.log

6 Showing a dialog box or writting text to the screen

7 Side effect: console.log(“Hello world”)
Produces a value: console.log(Math.max(5,10));
8 Code execution from top to bottom.

9 When code execution can vary based on the situation at hand (like with “if” statements).

10 else; else if

  1. An expression is a combination of operators and values, eg. 2 + 4

  2. A binding is the relationship between a variable and its value, the value can change depending on what the tentacle is garbing.

  3. The environment is the current state of all variable as they stand.

  4. A function is a subroutine, or a programme with your programme.

  5. An example of a function would be:

function ifElse(num1, num2, num3, num4) {
if ( (num1 > num2) && (num3 > num4) ) {
return num1 + num2;
}
else {
return num3 + num4;
}
}

  1. A side effect of a function is where the function adjusts a part of the programme that is not contained within it or is not the returned value

  2. An example of a function with a side effect is:

function ifElse(num1, num2, num3, num4) {
if ( (num1 > num2) && (num3 > num4) ) {
console.log(“Yes”);
}
else {
console.log(“No”);
}
}

  1. Control flow is the order in which the programmer executes the commands

  2. Conditional execution means that certain parts of the code will only be executed if a certain condition is met, an if/else statement is an example of this.

  3. If is the keyword used to exectude code conditionally.

  1. What is an expression?

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

  1. What is a binding?

In simple terms, a binding is a variable thatis used to retain information used in a program.

To define a binding, use the keywords “let”, “var” or “const”.

For example:
var pocket = 0;
const penny = 1;
let sample = 10;
pocket = sample * penny;

  1. What is an environment?

An environment is the collection of bindings and their respective values at any given point in time.

  1. What is a function?

A function is a small piece of code that operates on one or more values to produce some sort of output.

Functions may use externally provided values (known as arguments) which are used by the code within the function to affect it’s output.

  1. Give an example of a function.

console.log() is a great example of a function. It takes a value or expression as it’s argument, and prints the output of the function to the javascript console as a log entry.

  1. What is a side effect?

If the output of a function has a meaningful effect on the programs environment, it is know as a side effect.

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

The function with a binding called alert, produces a side effect of writing what ever argument is presented to it, to the screen. e.g. alert(“Warning”) will cause an alert box to appear on the screen.

However, some functions return a value, such as console’log(), which outputs it’s arguments to a text output device such as the javascript console available in browsers.

  1. What is control flow?

Control Flow is the normal execution flow of a program; which is normally top to bottom, one statement at a time. For example:

StartOfProgram;
ExecuteThisStatement;
ThenDoThis;
FollowedByThis;
EndOfProgram

  1. What is conditional execution?

Conditional Execution is where the program flow only executes a block of code IF and ony if certain conditions are met.

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

Conditonal Execution is normally achieved by the use of the if keyword. For example:

StartOfProgram;
if TheExecutionOfThisStaementIsTrue() {
ThenExecuteThisPieceOfCode();
};

  1. What is an expression? A fragment of code that produces a value.
  2. What is a binding? To catch and hold a value by which may or may not use an operator “let” Example let = bC; It then can be used as an expression. Two bindings can refer to the same value. Const stands for constant binding with the same value.*
  3. What is an environment? A collection of bindings and their values that exist in a given time.
  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: example: function testfunction(p1, p2) {
    return p1* p2;}
  6. What is a side effect? a program / function modifies the state of something else (outside its own scope), then it is producing a side effect.
  7. Give an example of a function that produces a side effect and another function that produces a value. alert (“Enter Your Name”); Console.log ; va r a = 25; var b = 10; console.log a * b)
  8. What is control flow? A program made up of statements with a start and an end.
  9. What is conditional execution? 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? the program branches using the “IF” statement.
  1. What is an expression?

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

  1. What is a binding?

A biding is a changing value or variable, which saves the assigned value.

  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?

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

  1. Give an example of a function.

Math.max(2,7)

  1. What is a side effect?

Showing a dialog box or writing text 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.

Example for function with side effect

alert(„Bitch“);

Example for funtion which produces a value:

Math.min(1,4);

  1. What is control flow?

A control flow shows, in which order multiple functions are executed.

  1. What is conditional execution?

A conditional execution means, that code is only executed if, and only if, a certain condition holds.

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

If

  1. A Fragment of codes which causes an value is caused an Expression
  2. Bindings are the storage of Memory or value, which you can Always refer back to when needed.
  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. example: alert(“invest in crypto”);
  6. positive side effect of functions are apperacences of a Dialog box for example.
  7. console.log(Math.max(2,4)); prompt(“Enter your Name”);
  8. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
  9. Conditional execution means that some part of the code is going to be executed only if certain condition
    is fulfilled( true ).
  10. Conditional execution is created with the if keyword in JavaScript