Binding, Functions and Control Flow - Reading Assignment

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: A binding is a value or string that is set to a variable. You can store something and create a link that you can use in expressions.

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: prompt(""); alert("");

6: If the programs changes something in the browser, like showing a dialog box, writhing text to the screen,… that is a side effect by the program.

7: prompt(""); alert(""); var a = 1
var a = 1
var b = 2
console.log(a+b);
3

prompt(" type in password ");

8: Control flow is the order in wich the program is written. top to bottom, left to right.

9: If the program has diffirent branches, where the program has to take the proper branch depending on the situation at hand.

10: “if” / “else” .

1 Like

An expression is an operation thatproduces a value
a binding is a variable that stores or binds a value
the environment is a collection of bindings and their values.
A function is a piece of code wrapped in a value.
function (a, b) {
return a * b;
}
A side effect is a dialgoue box or text on the screen.
7, prompt("hello’);

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

  1. It is the way the programme runs from top to bottom.
  2. It is the execution of code based on different conditions being met.
  3. if.
1 Like
  1. An expression is a piece of code that produces a value.
  2. Binding describes how a variable is created and used.
  3. An environment is a collection of variables and their values as they exist at a given time.
  4. A function is a piece of program contained in a value.
  5. An example of a function is “prompt”.
  6. An example of a side effect is showing an alert box.
  7. An example of a function that produces a side effect is:
    alert(“Hello there!”);
    an example of a function that produces a value is:
    Math.max(2, 4);
  8. Control flow is the order of execution.
  9. Conditional execution performs different actions when a result is either true or false.
  10. The kind of keyword do you need to use to invoke conditional execution is “if”.
2 Likes

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

What is a binding? A binding points a name to a value

What is an environment? A collection of default bindings and their values that are part of the language standard

What is a function? A function is a piece of cade designed to execute a particular task when something invokes (calls) it

Give an example of a function. prompt(‘Enter password’);

What is a side effect? A side effect is when a function is showing something on screen as a written text or a dialox box

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

Side effect -> Prompt (“Congratulations! You just won a iPhone”); will create a dialog box with the text Congratulations! You just won a iPhone

Value -> console.log(Math.max(2, 4)); // ->4 The function will return the biggest value which is 4

What is control flow? A program containing more then one statement

What is conditional execution? This is a piece of code which get’s executed only if a certain condition have been met

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

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

  2. A binding catches and holds values in Javascript. It’s also called variable. A keyword can define a binding.

  3. The collection of binding and 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 to run the wrapped program. Executing a function is called: invoking, calling or applying.

  5. An example of a function is the prompt function that uses the string of text to show inside a dialog box.

  6. A return value such as a dialog box or text to the screen is called a side effect.

  7. A side effect can be an alert message, login to a website.
    Value functions are math equation.

  8. A control flow is when a program contains more than one statement and the statements are executed from top to bottom - a linear path.

  9. A conditional execution is not linear, it’s based on conditions. For example: if you’re over 21…, if your under 21…

  10. The conditional execution is created with the keyword, “if.”

2 Likes
  1. What is an expression?

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

  1. What is a binding?

A thing that Javascript provides to catch and hold values.

  1. What is an environment?

An environment 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 is a function. It could be used like this:

Prompt(“Enter passcode”);

  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.

console.log(Math.max(3, 5));

// → 5

console.log(Math.min(3, 5) + 55);

// → 58

  1. What is control flow?

Control flow is when your program contains more than one statement, the statements are executed from top to bottom.

  1. What is conditional execution?

Conditional execution is when you want to create a branching road where the program takes the proper branch based on the situation.

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

You need to use ‘if’.

2 Likes
  1. A value that is written literally.

  2. Something that ties a value, but not forever.

  3. The collection of bidding that exist for the moment.

  4. A piece of program wrapped in a value.

  5. console.log("")

  6. Something that changes the the state outside of itself.

  7. prompt(“Enter name”);
    console.log(math.min(3, 5));

  8. The order in which the code is executed.

  9. It will only happen if something specific has happened/meets previous conditions.

  10. if, else, else if

2 Likes

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

2.) A binding is a variable that hold/grasp a value which must be clearly defined in its data type ( of string, char, number, and boolean) when created. This can be summed up as var or const as the case may be.

3.) An Environment is a collection of bindings and their values at a given time which provide ways to interact with the surrounding system.

4.) A function is a piece of program wrapped in a value with parentheses. The Values, given to the function, within the parentheses are called argument or parameter which can be as many as possible. or no parameter at all in the parentheses.

5.) Example of a function: function myFunction (a,d,e);

6.) A side effect is the output of an expression evaluated changes the internal structure/state of the function or of the object which are out the system (i.e the global variables).

7.(a) example of a function that produces a side effect:
var a = 10;
var b = 20;
function myFunction (10 ,20) {
const d = a+b;
return d;
}
console.log (d);

(b) example of a function that produces a no side effect:
function myFunction (a ,b) {
const d = a+b;
return d;
}

8.) Control Flow is also called Flow of Control (like flow chart), is the order in which elements of a computer program - instructions, statements and function calls - are executed and evaluated usually in sequence (i.e one after the other from top to the bottom, unless selection or iteration is used.

Selection refers to a decision made by the program which determines which part of the code is executed based on the result of some action.

9.) Conditional Execution: Most programming languages uses control flow statements with conditional executions such as IF, THEN and ELSE to make these decisions upon when certain conditions are met.

10.) The if keyword

2 Likes

1. What is an expression?
anything that produces a value is an expression
2. What is a binding?
an other name for variable, it points at a value, this value can change in time
3. What is an environment?
the collection of bindings and their values that exist at a given time
4. What is a function?
a funtion is a piece of program wrapped in a value
5. Give an example of a function.
prompt (“enter password”)
this will show a pop up box with a text “enter your password”
6. What is a side effect?
if something happens, something pops up, something is activated, shown etc.
7. Give an example of a function that produces a side effect and another function that produces a value.
prompt(“enter a value” ) side effect a popping window
1; this produces the value 1
8. What is control flow?
the order in which statements are executed in a program
9. What is conditional execution?
a point in the program where depending on the input one route or the other is chosen. This is created with the keyword if
10. What kind of keyword do you need to use to invoke conditional execution?
if ,else, while,

2 Likes
  1. Expressions are contents which produce a value.
  2. Binding is a process which links variables to a value.
  3. Environment is a collection of bindings and their values that exist at a given time.
  4. Function is a piece of program wrapped with a value.
  5. A example of a function is Number, used to convert a string value into a number value.
  6. Side effect is a result of function, which changes how a machine affect statements.
  7. Prompt function creates a side effect which is a dialog box for user’s inputs. The Math.max function chooses and returns the largest value from a set of values given in the argument.
  8. Control flow is the procedure in which statements are executed.
  9. Conditional execution refers to the resulting running of code based on scenarios and inputs.
  10. If, Else.
2 Likes
  1. A fragment of code that produces a value is called an expression.

  2. Binding allows you to catch and hold values. You can then use the value as 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.

  5. prompt
    console.log

  6. A statement that could change the internal state of the machine in a way that will affect the statements that come after it.

  7. console.log(Math.max(2, 4));
    console.log(Math.min(2, 4) + 100);

  8. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.

  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
    Else

2 Likes
  1. Expression - a fragment of code that produces a value
    Expression - An expression corresponds to a sentence fragment.
    An expression can be content to just produce a value.
    Statement - A JavaScript statement corresponds to a full sentence.
    Ends with semicolon ‘;’
    Program - A program is a list of statements.
  2. Binding - to catch and hold values
    JavaScript provides a thing called a binding, or variable
  3. Environment - collection of bindings and their values that exist at a given time
  4. Function - is a piece of program wrapped in a value
    Values given to functions are called Arguments
  5. Function Example - prompt(“Enter passcode”);
  6. Side Effect - statements that affects the ‘World’
    Statements that changes the displays or the internal state of the machine
    in a way that will affect the statements that come after it.
  7.  side effect -  Showing a dialog box or writing text to the screen - prompt(“Enter your name”);
     value - results in a value - console.log(Math.max(2, 4));
    
  8. Control Flow - order in which the computer executes statements in a script.
  9. Conditional Execution - branching, where the program takes the proper branch based on the
    situation at hand.
  10. Conditional Execution Invocation - Keyword - ‘IF’
2 Likes
  1. an expression is a line of code ex (nan + nan) or nan;
  2. A binding is an link between to values.
  3. An enviroment is an amount of code written between {}.
  4. A function is basically a small program applied by invoking the function keyword.
  5. An example of a function is
    count apples (jamies apples, ivans apples) { return jamies apples + ivans apples;}
    6.a side effect is an action a function generates either on screen or within the program.
  6. a function that gives a side effect would be
alert ("helllllllllooooo Ivan"); a function that gives us values would be console.log(math.min(20,21)+400) 420 8. Control flow describes how the computer will execute the code from top to bottom and left to right. breaking the commands with a ; 9. A conditional execution is a limiting piece of code in which it applies a rule. 10 If is the keyword used to invoke or call and execution.
1 Like
  1. A fragment of code that produces a value.

  2. A thing to 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. prompt(“Enter passcode”);

  6. Showing a dialog box or writing text to the screen. A lot of functions are useful because of side effects like these.

  7. produces value only --> console.log(Math.min(2, 4));
    produces a side effect could be achieved with alert etc.

  8. When your program has multiple statements, the statements are executed as if they are a story, from top to bottom.

  9. A fragment of code is only excecuted if a certain condition is met.

  10. if

1 Like

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

What is a binding? The method that a program uses to store values.

What is an environment? A collection of bindings and their values.

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

Give an example of a function. console.log(“doggy-dayz”)

What is a side effect? Showing a dialog box or text on the screen…

Give an example of a function that produces a side effect and another function that produces a value. Console.log(“groupies”); console.log(5 + 7);

What is control flow? The order of which program statements are executed: from top to bottom like a story.

What is conditional execution? In executing statements, a program is given the ability to take a different execution path based on the previous outcome.

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

2 Likes
  1. An expression is another way of writing the variables/values. Think of it like a math problem, a+b=c a+b is an expression of c
  2. A binding is a variable. A binding is a temporary way to define a value. The program may get “confused” seeing a word like ten or fifty, so we use a binding to define the word and to use the value in the binding whenever the word ten or fifty is used.
  3. An environment uses the entire collection of bindings and their values.
  4. A function is a program defined by a value. When we use the value then that program will be executed/invoked.
  5. prompt (“Enter passcode”);
  6. A side effect is what happens when a statement will change the environment or future state of things.
  7. prompt(“Enter passcode”) has the side effect of a dialogue box popping up that will say Enter passcode.
    console.log(Math.min(2,4,6,8)); will return you the minimum value entered.
  8. The control flow is the standard way the program is read, written, and executed.
  9. Conditional execution takes the path in different directions depending on certain conditions.
  10. if
1 Like

i. What is an expression? An expression is a fragment of code that produces a value.
ii.What is a binding? Also known as a variable, a binding catches or holds a value.
iii.What is an environment? The environment is a collection of bindings and values at an instant of time.
iv. What is a function? A function is a fragment of code wrapped in a value. It may have arguments and always produces an output, even if it ‘undefined’.
v. Give an example of a function. console.log().
vi. 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 (e.g., a global variable, or a variable in the parent function scope chain) Logging to the console.
vii. Give an example of a function that produces a side effect and another function that produces a value.
1. Function that produces a side effect: alert().|
2. Function that produces a value: Math.max(a,b).|
viii.What is control flow? The control flow is the order in which the computer executes statements in a script. … A typical script in JavaScript includes many control structures, including conditionals, loops and functions. Parts of a script may also be set to execute when events occur.
ix.What is conditional execution? Conditional execution occurs when a program takes a branch based on a value of true or false.
x.What kind of keyword do you need to use to invoke conditional execution? If, else if, else, while and do.

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

  2. What is a binding?
    ⁃ A binding is the simple fact of giving a name to a value or another string. allowing you to use that string or value instead of having to write the value bound to it over and over. Bindings only pertain to the most recent binding at the time. For example if you wrote your code like this:
    ⁃ let mood = “light”; console.log(mood); // → light
    ⁃ let mood = “dark”; console.log(mood); // → dark
    ⁃ Bindings can also have any name but it must not start with digits. Another special rule is that it may contain $ or _ but no other special characters.

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

  4. What is a function?
    ⁃ a functions is a piece of program wrapped in a value. Values can be applied in order to run the wrapped program.

  5. Give an example of a function.
    ⁃ One example would be in a browser environment the binding prompt holds a function that shows a little dialog box asking for user input.

  6. What is a side effect?
    ⁃ a side effect what happens when a statement affects another statement within the code which makes changes maybe visually or within the code itself prompting maybe programs to run or some kind of action to be made.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    ⁃ An example for a function that produces a side effect would be as listed above, when prompted to show a dialog box.
    ⁃ An example of a function that produces a value is the math.max function. it takes any amount of number arguments and gives back the greatest of the numbers.

  8. What is control flow?
    ⁃ Its when a program contains more then one statement. The statements are executed top to bottom.

  9. What is conditional execution?
    ⁃ conditional execution is a way of telling the program to run a different code depending on the situation. which is why it is represented by the “if” keyword. So it only runs if and only if something is true to make that function run.

  10. What kind of keyword do you need to use to invoke conditional execution?
    ⁃ You would use the “if” and “else” keywords.

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

  2. A binding is used to remember values.

  3. An envirment is a group of bindings that is around at a given time.

  4. A function is a piece of programe that is wraped inside of a value.

  5. You would use a function to put up a textbox, an alert, or console.log.

  6. A side affect is what the function puts up, like a text box.

  7. Math.max produces a value.

  8. The control flow is what makes the progam execute in a specefic fassion.

  9. A conditional execution is when the program braches off the main path if a certain condition holds.

  10. To use the if keyword to invoke a conditional execution.

1 Like

What is an expression?

A fragment of code that produces a value. This could be a word or a number, or even operators between 2 expressions

What is a binding?

A word (keyword) in a program that that acts to keep a value’s state permanent, by “pointing to” or linking to that value The name of the binding itself becomes an expression after it is created.

What is an environment?

The environment is all bindings and corresponding values that exist at a given time. They are pre-populated when you run a program.

What is a function?

A function is a piece of program wrapped in a value. It is placed after a binding word

Give an example of a function.

prompt(“click next to continue”);

What is a side effect?

It is a result of invoking a function, eg a pop up prompt on a website

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

prompt(“Enter passcode”);
Will pop up a dialog box on a website

(Math.max(2, 4));
Will compare and return the greater of the 2 numbers

What is control flow?

Sequential execution of statements in strict order from top to bottom. (If a program contains more than one statement)

What is conditional execution?

Program will execute code or take a course of action depending on the condition at that point in time

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

Conditional words like: if, else

1 Like