Binding, Functions and Control Flow - Reading Assignment

  1. An expression can be defined as multiple definitions such as code that produces a value, written values, what is between parentheses and also a binary operator having two expressions + a unary operator applied to one.
  2. Binding is what is done is Javascript to catch and hold values. A special keyword such as let can indicate that the sentence will use the binding feature. There are typically 3 used binding keywords being let, var and const. Binding is possible to change as well by breaking the bindings with the equal sign(=), therefore letting another value be imputed.
  3. An environment is a collection of bindings and their values that exist at a given time. When communicating with a program on the computer, there will be bindings that are part of the standard language and most of the time with the surrounding system. An example of this would be a browser, when it starts up, there will already be code ready to activate with a loaded website.
  4. A function is a piece of program wrapped in a value. It is a block of code designed to perform a particular task. A function is known as a value which can be numbers, pieces of text, etc.
  5. A couples examples of functions are:
    function avg(a,b) {}
    and also
    function square(x) {return x * x; }
  6. A side effect in Javascript is typically when a dialog box is shown or when text is written to the screen. Depending on how the code is written with the function being inputted and the following values being defined, different effects can be produced.
  7. A function that produces a side effect would show a dialog box or text written to the screen with this example of a function that produces a side effect:
    prompt(" Enter passcode" );.
    Functions can also produce values, where to side effect is needed to be considered useful. An example is as follows:
console.log ( Math.max (2, 4)) ;
//-> 4
  1. Control Flow is when the action of executing statements in the form of a story, from top to bottom take place when multiple statements are present together.
  2. Conditional execution is used in a situation where different paths can be created, thus letting the program take the proper path, based on what is happening in the situation at hand.
  3. In order to call up the conditional execution, the keyword ‘if’ is needed. In this situation, separate code for both paths, upon execution will be present in order to create alternative execution paths. Another part of this includes the ‘else’ keyword which will continue the paths in order to find the right solution in the situation.

I was getting stuck multiple times on this assignment and feel with coming back to it multiple times, my understanding has improved. I really want to understand all the key terms and have q-cards handy to help.

Edit @ivga80: You can use the preformatted text when you want to show code in the post. Nice job. :wink:

1 Like

I think it was a good and complete answer.
And its nice to have some q-cards handy, yes. :man_teacher:
Ivo

  1. What is an expression? It returns a value.

  2. What is a binding? To catch and hold values, JavaScript provides a thing called a binding, or
    variable:

  3. What is an environment? A collection of bindings or variables.

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

  5. Give an example of a function. The variable "prompt"holds a function that will open a small dialog box
    for user imput.

  6. What is a side effect? Showing a dialog box or writing text to the screen is a side effect… 7.Give an example of a function that produces a side effect and another function that produces a value.
    a. prompt. b.Math.max

  7. What is control flow? The order that statements are executed.

  8. What is conditional execution? the execution of the programe takes dirrection depending differant
    factors.

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

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

  2. What is a binding?: It’s a variable, an identifier that holds a value

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

  4. What is a function?: It’s a binded/identified sequence of statements/instructions, a piece of program wrapped in a value

  5. Give an example of a function.: alert( “hello” ) or console.log( 10 )

  6. What is a side effect?: It’s the event triggered by a function call

  7. Give an example of a function that produces a side effect and another function that produces a value.: alert produces a side effect, Math.max returns a value

  8. What is control flow?: It’s the order in which a program’s statements are executed

  9. What is conditional execution?: It’s a branching in the control flow, where different code paths can be executed at different conditions

  10. What kind of keyword do you need to use to invoke conditional execution?: ïf" and “else” statements

1 Like
  1. It’s code that results in a single value

  2. They point to the value of a variable

  3. A collection of bindings and values

  4. Stores the entire expression in a function so you don’t have to write out the entire expression again if you want to use it again, you can just use the name of the function

  5. alert(“hello”);

  6. Showing a dialogue box or writing text to the screen is a side effect.

  7. Value example
    prompt(“Enter your age”);
    Side effect example
    console.log(Math.min(2, 4));
    2

  8. When there is more than 1 statement, the control flow is the order in which it executes.

  9. Conditional execution is if/else which means if true do (this) else if false do (this).

  10. If and else

1 Like
  1. What is an expression?
  • An expression is a fragment of code that produces a value
  1. What is a binding?
  • A binding is the idea of catching and holding value. These can also be referred to as variables and a second type of statement
  1. What is an environment?
  • It is the collection of bindings and their values that exist at a given time
  1. What is a function?
  • A function is a piece of program wrapped in a value
  1. Give an example of a function.
  • Prompt (“Enter Passcode”);
  1. What is a side effect?
  • A side effect is showing a dialog box or writing text to the screen
  1. Give an example of a function that produces a side effect and another function that produces a value.
  • Value:
    • console.log(Math.max(2, 4));
  • Side effect:
    • Prompt (“Enter Passcode”);
  1. What is control flow?
  • Control flow occurs when there is more than one statement in a program; thus, it is the program’s duty to read each statement in a sequential order from top to bottom, similar to a story.
  1. What is conditional execution?
  • A conditional execution is created with “if” statements. With these types of statements, the execution of the program only occurs if, and only if, a certain condition holds.
  1. What kind of keyword do you need to use to invoke conditional execution?
  • To invoke a conditional execution, an “if” statement must be used.
1 Like
  1. A fragment of code that produces a value
  2. Assignment of internal state used to catch and hold values
  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 Password”)
  6. A side effect is any application state change that is observable outside the called function other than its return value.
  7. console.log(firstAccount);
    var firstAccount = accounts[0];
  8. It is the direction of execution of code in JavaScript which happens in a top down approach.
  9. the program takes the proper branch based on the situation at hand
  10. If, else
1 Like

1. What is an expression?
A fragment of a code that produces a value
2. What is a binding?
A statement in JavaScript that will catch and hold values
They work like tentacles, they grasp
3. What is an environment?
All existing bindings and values, not only within the program but within all programs needed to run the particular program
4. What is a function?
A piece of program wrapped in a value
5. Give an example of a function.
Alert(“Balls to the wall!”);
6. What is a side effect?
For example showing a dialogue box or writing 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: Prompt(“pick a number”);
Value: console.log(Math.max(2, 4));
8. What is control flow?
The order of statements in a program, they run from top to bottom
9. What is conditional execution?
Code with branches that execute only if certain conditions are meet
10. What kind of keyword do you need to use to invoke conditional execution
If

1 Like
  1. An expression is any operation that returns a value.

  2. Binding is used to give objects context.

  3. An environment is the scope within which your program is running.

  4. A function is a way to create dynamic behavior in your program.

  5. function Sum(a, b){
    return a+b
    }

  6. A side-effect is when a function changes a value outside of the scope the function

Side-Effect:
let x = 0
function increment(){
x++
}
Value:
function sayHello(){
return “Hello”
}

  1. Control flow is how you can handle different states in your programs

  2. Conditional execution is when you process certain lines of code under defined circumstances.

  3. Conditional statements are defined with the if keyword.

1 Like
  1. What is an expression?
    A fragment of code that returns a value

  2. What is a binding?
    Bindings are variables used to store a value in JS

  3. What is an environment?
    collection of variables and values that exist at a given time is the environment
    All of the variables loaded into memory and available for use in a given session.

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

  5. Give an example of a function.
    prompt
    alert
    console.log

  6. What is a side effect?
    Showing an alert box or writing to the screen

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Alert produces a side effect
    Math.min returns the min value based on provided arguments

  8. What is control flow?
    The flow of which code is read by the program. It is typically top to bottom and left to right

  9. What is conditional execution?
    an expression that is evaluated IF a condition is met

  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?
    An expression is a fragment of code that produces a value.

  2. What is a binding?
    A binding, or a variable, is a connection to values. A binding points to something.

  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.

prompt(“Enter passcode”);

  1. What is a side effect?
    A side effect is showing a box on the screen or writing text to the screen.

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

  3. What is control flow?
    The control flow represents the order of executing statements within a program.

  4. What is conditional execution?
    Conditional execution regulates which set of statements should be executed and which should be ignored based on changing conditions.

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

1 Like
  1. Any part of the program that produces a value is an expression.

  2. Binding is reassigning a this used within a function. Bind is used outside of a function.

  3. An environment is all variables and their values within a program at any time. Even when a program is empty it can include start up variables and values.

  4. A function is a set of statements that calculate or follow a set of instructions typically based on a set of variables given to it.

  5. An alert function takes an input and creates a popup with the input displayed.

  6. A side effect is either changing a variable value, changing the internal state of a program or completing some sort of an action such as the alert function.

  7. A function that produces a side effect could be:
    function test(x) {
    x+= 1;
    }
    A function that produces only a value would be
    function test1(){
    1+2;
    }

  8. A control flow is the order in which a program executes commands.

  9. Conditional execution is using if else statements or else if statements to affect the control flow of a program.

  10. Keywords to invoke conditional execution include: if, else if, and else.

1 Like

1.An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value.
2. Imagine bindings as tentacles, a program can access only the values that it still has a reference to. When you need to remember something, you grow a tentacle to hold on to it or you
reattach one of your existing tentacles to it.
3.The collection of bindings and their values that exist at a given time is called
the environment. When a program starts up, this environment is not empty. It
always contains bindings that are part of the language standard, and most of the
time, it also has bindings that provide ways to interact with the surrounding
system.
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(“How old are you”);
6.Showing a dialog box or writing text to the screen. Any application state change that is observable outside the called function other that its return value.
7.prompt(“Name”) -side effect
console.log (2 + 4); -value
8. Starting top to bottom, the execution flow when you have more than one statement.
9. A point where the program decides what to do based certain conditions.
10. If, else

1 Like
  • What is an expression?
  • A fragment of code that produces a value.
  • What is a binding?
  • Bindings are like tentacles, they grab or catch values whenever is needed.
  • What is an environment?
  • A collection of bindings and their values that exist at any given time.
  • What is a function?
  • Is a piece of program wrapped in a value.
  • Give an example of a function.
  • The function number converts a value to a number:

let theNumber = Number(prompt(“Pick a number”));
console.log("Your number is the square root of " + theNumber * theNumber);

  • What is a side effect?
  • Is a statement changing the world, for example showing a Dialog box on the screen.
  • Give an example of a function that produces a side effect and another function that produces a value.
  • the promp function produces a side effect:
    promt(“Enter passcode”)
    will show a Dialog box

  • the Math.max function produces value:
    console.log(Math.max (5 , 7));
    // 7

  • What is control flow?
  • is the way the statements are executed, like a story line, from top to bottom.
  • What is conditional execution?
  • Is when we want to execute some code only if a certain condition applies. For example, creating a branching road where a program will take the proper branch based on the specific situation defined by us.
  • What kind of keyword do you need to use to invoke conditional execution?
  • if, else, else if
1 Like
  1. What is an expression?
    A fragment of code that produces a value is called an expression.

  2. What is a binding?
    Bindings are used 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. Such values can be applied in order to run the wrapped program.

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

  6. What is a side effect?
    If a function modifies the state of something else it has a side effect.

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

  8. What is control flow?
    Statements are executed from top to bottom

  9. What is conditional execution?
    The program 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, Else

1 Like
  1. What is an expression?

A fragment of code that produces a value, or anything written literally.

  1. What is a binding?

A mechanism to catch and hold bindings. They are like tentacles, not boxes.

  1. What is an environment?

A collection of bindings that exist in the program at a given time, including things present upon start up, i.e. the mouse on a website.

  1. What is a function?

A piece of program wrapped in value, designed to perform a particular task. You can invoke a function by putting parentheses operator after an expression that produces a function value.

  1. Give an example of a function.

function myFunction(p1, p2) {
return p1 * p2;
}

  1. What is a side effect?

A visual response to a function, including text or values appearing on screen.

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

prompt(“enter passcode”);

console.log(Math.max(10, 15) + 50);

  1. What is control flow?

When multiple statements are present, they are executed top to bottom, like a story.

  1. What is conditional execution?

Not all programs have linear control flow, they can have multiple branches depending on the inputs they receive.

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

Invoked by if. else, while, loop

1 Like
  1. What is an expression?

A fragment of code that produces a value.

  1. What is a binding?

It is also a variable. It allows JavaScript to catch and hold values.

  1. What is an environment?

The collection of bindings and their values.

  1. What is a function?

A piece of program wrapped in a value.

  1. Give an example of a function.

prompt(“Enter password”);

  1. What is a side effect?

Showing a dialogue box or text to the screen from commands.

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

console.log(“Hello, World!”);

console.log(Math.max(2, 4));

  1. What is control flow?

The order of executions according to commands.

  1. What is conditional execution?

It is created with the if keyword. It executes if a condition holds true.

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

if.

1 Like
  1. Expressions are Javascript code snippets that result in a single value.
  2. A binding is a (?) that binds a value to a (?)
  3. The javascript environment are all objects and libraries that are available to you.
  4. A function is a block of code designed to perform a particular task.

(not finished)

  1. Expressions is a piece of code that resolves a value. Examples of expressions in JavaScript are Strings which evaluates a string and an Arithmetic string which resolves to a number.

  2. Bindings are how a a program remembers, When we bind something such as a = 2, when the program is executed and it comes across the variable a it will be associated with the number 2 unless we program it differently.

  3. Any collection of bindings that exist within a program is called the environment.

  4. A function is a part of the code that executes a particular task.

  5. alert(“This is a function”);

  6. A side effect is the part of the function which does something other than returning a value, such as printing the value to the screen.

  7. a = true
    b = true
    if (a+b) {
    “true”
    }

  8. Control flow is the order that functions are executed in a program. if else statements can be used to do this.

  9. Conditional executions are used to establish which functions will be executed given the specified boolean value is either true or false.

  10. AND, OR, NOT and NEAR

1 Like
  1. A fragment of code that produces a value.

  2. It catches and holds value, it can be any word and a digit as long as it starts with a name.

  3. The collection of bindings and their values.

  4. A piece of program/code wrapped up in a value.

  5. var a = true;

  6. Writing text to a screen or dialog box.

  7. Side effect = Console.log
    Function that produces a value > a = true

  8. When your program contains more than one statement. From top to bottom.

  9. It uses the if keyword and the value is created after a keyword.

  10. If, else

1 Like