- A fragment of code that produces a value.
- A binding is the association of a variable name with the variable entity.
3 . An environment is the collection of bindings and their values that exist at a given time. - A function is a piece of program wrapped in a value.
- Prompt
- A side effect is any application state change that is observable outside the called function other than its return value.
- The arg function produces a value and the setTimeout() function is a side effect.
- Control flow is how your computer runs code from top to bottom. It starts from the first line and ends at the last line, unless it hits any statement that changes the control flow of the program such as loops, conditionals, or functions.
- Conditional statements, , which are used to perform different actions based on different conditions.
- if/else/else if/switch
Expression = âa fragment of code that produces a valueâ.
Binding catches and holds values.
The collection of bindings and their values that exist at a given time is called
the environment.
A function is a piece of a program wrapped in a value.
Showing a dialogue box or writing text to the screen is a side effect.
The prompt function produces a side effect. Functions such as var produce value.
Control Flow is the order in which the code is executed.
Control Execution is when you have an âifâ in the coding. The âifâ branch of the coding would only execute when its condition is met.
âIFâ is the keyword for invoking conditional execution.
What is an expression?
A fragment of code that produces a value is called an expression. Every value that is written, literally is an expression.
What is a binding?
Binding means to catch or hold values. They do not contain the values but grasp them as 2 binding can be referred to the same 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 value
Give an example of a function.
The prompt function uses the string that we give it as text to show in the dialog box.
Eg: prompt(âWhat is your nameâ);
What is a side effect?
Showing a dialog box or writing text to the screen is a side effect.
Give an example of a function that produces a side effect and another function that produces a value.
The binding prompt holds a function that shows a little dialog box asking for user input. It is used like this: prompt(âEnter passcodeâ);
The function Math.max is another example of a function that takes any amount of number arguments and gives back the greatest: console.log(Math.max(, 4));
// > 4
What is control flow?
When your program contains more than one statement, the statements are executed as if the are a story, from top to bottom.
What is conditional execution?
Not all programs has a straight forward path, we can create other paths to choose from where the program takes the solution based on the situation at hand. This is called conditional execution.
What kind of keyword do you need to use to invoke conditional execution?
The keyword âifâ is an example of conditional execution in JavaScript, in simple case, its a function code to be executed if, and only if, a certain condition holds.
1. What is an expression?
An expression is a fragment of code that produces a value. It is any valid set of literals, variables, operators, and expressions that evaluates to a single value.
2. What is a binding?
Binding is done for each variable and functions. Javascript uses special keywords (var, let, const) followed by a name identifier and operator to indicate that this declaration is going to define a binding and store some information that can be called upon at a later time in the program.
/*
Binds a name identifier "number" to the let keyword and
sets it = to 10. The value 10 will be stored in the
number variable and can be called at a later time.
*/
let number = 10;
3. What is an environment?
The collection of bindings and their values that exist at a given time is called the environment. This is where our code runs and executes stored instructional information .
4. What is a function?
A function is a piece of information wrapped in a value. Such values can later be called in order to run the wrapped program.
5. Give an example of a function.
The following example is a simple named function called greeting that takes a name as an argument(parameter). The instructions tell it to return the word âHelloâ and the name of the argument that is passed to the function when called.
When greeting is called you pass in the name parameter it expects to receive.
function greeting(name) {
return "Hello " + name + "!";
}
console.log(greeting("Rose"));
/*
Returns:
Hello Rose!
*/
/*
May also be written as an
anonymous function:
*/
let greeting = function(name) {
return "Hello " + name + "!";
};
console.log(greeting("Rose"));
6. What is a side effect?
Showing a dialog box or writing text to a screen is a side effect. It is any application state change that is observable outside the called function other than its return value.
They can also be mutations or actions that happen in our code environment that we cannot make an account of. It could result in pollution of the global scope.
7. Give an example of a function that produces a side effect and another function that produces a value.
let welcome = alert("Welcome to the web browser!");
let input = prompt("What is your name?");
let age = 2;
function changeAge() {
age = 6;
return age;
}
console.log(changeAge());
// 6
8. What is control flow?
When your program contains more than one statement, the statements are executed as if they are a story.
The control flow is the order in which the computer executes statements in a script. Code is run in order from the first line in the file to the last line, unless the computer runs across the (extremely frequent) structures that change the control flow, such as conditionals and loops.
9. What is conditional execution?
Conditional statements allow us to represent such decision making in JavaScript, from the choice that must be made, to the resulting outcome of those choices.
10. What kind of keyword do you need to use to invoke conditional execution?
Javascript Conditionals:
âIfâ statements: where if a condition is true it is used to specify execution for a block of code.
âElse ifâ statements: this specifies a new test if the first condition is false.
âElseâ statements: where if the same condition is false it specifies the execution for a block of code.
-
What is an expression?
⢠An expression is a fragment of code that produces a value. -
What is a binding?
⢠A binding, or variable, is something that can catch and hold values. -
What is an environment?
⢠The collection of bindings and their values that exist at a given time is the environment. -
What is a function?
⢠A function is a piece of program wrapped in a value. -
Give an example of a function.
⢠ex: prompt(âEnter Usernameâ); -
What is a side effect?
⢠A side effect is when a statement changes something that either changes something in the world or in a way that changes the internal state of the machine that will affect the statements that come after it.
Showing a dialog box or writing text to the screen is a side effect. -
Give an example of a function that produces a side effect and another function that produces a value.
⢠A function that produces a side effect would be something like: prompt(âEnter date of birthâ);
A function that produces value would be something like: console.log(1+2); -
What is control flow?
⢠Control flow is when your statements read like a story from top to bottom. -
What is conditional execution?
⢠Conditional execution is when the program takes the proper path based on the situation at hand instead of flowing like a story. -
What kind of keyword do you need to use to invoke conditional execution?
⢠To invoke conditional execution you need to use the âifâ keyword.
- What is an expression?
An expression is a fragment of code that produces a value.
- What is a binding?
A binding attaches a variable to a value.
- What is an environment?
An environment is 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. When a function receives an input, it will return an output.
- Give an example of a function.
F(x) = x + 1
- What is a side effect?
A side effect is an observable event or output that happens that is not the main effect of the function.
- Give an example of a function that produces a side effect and another function that produces a value.
Side effect of creating a prompt box: prompt(âEnter a numberâ)
Produces a value: console.log(2 +2)
- What is control flow?
The control flow is the order in which statements are executed, usually from top to bottom.
- What is conditional execution?
An execution that happens when a certain condition is met, usually by using the âifâ function.
- What kind of keyword do you need to use to invoke conditional execution?
The âifâ keywork is used to invoke conditional execution.
-
An expression is a fragment code that produces a value.
-
A binding is a variable and it is used to catch and hold values.
-
An environment is a collection of bindings and their values that exist in a given time.
A program always contains bindings which are part of the language standard and it has bindings that provide ways to interact with the surrounding system. -
A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.
-
Example of a function, a function in a browser environment the binding prompt holds a function that shows a little dialog box asking for user input: prompt ("Enter passcode:);
-
A side effect is the output from a binding, or function writing text to the screen.
-
A function that produces a side effect is the prompt function. The function of (Math.max) brings back a value. The prompt function produces a side effect. The function of Math.max brings back a value eg: console.log(Math.max(2,4));
// 4 -
Control flow is the order of execution of a program containing more than one statement. The statements are executed from top to bottom as if they are a story.
-
A conditional execution is created with the if key word in JavaScript. We want some code to execute if the only if - a certain condition is met - than the code can be executed.
-
The type of keyword to invoke conditional execution is: console.log();
- What is an expression?
A fragment of code that produces a value. At its simplest a value typed literally is an expression.
- What is a binding?
A binding is another word for a variable - it stores values to be referenced later.
- What is an environment?
An environment is a set of bindings that are defined. A default JavaScript environment will load a number of standard bindings to start with.
- What is a function?
Functions are special values that encapsulate a piece of program.
- Give an example of a function.
prompt(âEnter passcodeâ) would trigger a popup in a browser, though it is not often used any more as you canât control the styling.
- What is a side effect?
A side effect is a visible impact a function has, such as displaying a window prompt. A function that creates a value is internal to the code and need not display anything.
- Give an example of a function that produces a side effect and another function that produces a value.
Pproduces the side effect of printing text to the popup dialogue box:
prompt(âThis is a side effectâ);
Outputs the highest value:
console.log(Math.max(2,4));
- What is control flow?
The order of execution of multiple statements from top to bottom.
- What is conditional execution?
Executing a section of code depending on certain circumstances being met.
- What kind of keyword do you need to use to invoke conditional execution?
if, while, do, for, switch (though a chain of if statements may be preferable to switch which was inherited from C/Java).
-
A fragment of code that produces a value even between parentheses.
-
Made to catch and hold values as per variable do as well. Itâs like tentacles, rather than boxes.
-
Collection of bindings and their values that exist at a given time.
-
A piece of program wrapped in a value. Such values can be applied in order to run the wrapped program. Can have multiple parameters or no parameters at all.
-
prompt(âEnter passcodeâ);
Produces a box which we can insert a passcode. -
Changes that produce the values 1 and true and then immediately throw them away. This leaves no impression on the world at all, nothing observable happens.
-
const makeNoise = function () {console.log(âPling!â); makeNoise(); // Not a value
const square = function(x) {return x * x;};
console.log(square(12)); VALUE -
Program contains more than one statement, the statements are executed from top to bottom. The first one asks the user for a number, and the second, which is executed after the first, shows the square of that number.
-
Wants some code to be executed if, and only if, a certain condition holds. Creates a branching road, where the program takes the proper branch based on the situation on hand.
-
With the if keyword in JS.
-
What is an expression?
A fragment of code that produces a value is an expression. -
What is a binding?
Binding means to catch and hold value. -
What is an environment?
The environment is the collection of bindings and their values at a given time. -
What is a function?
A function is a piece of value wrapped in a function. -
Give an example of a function.
prompt(âenter anythingâ); -
What is a side effect?
Showing a dialog box or writing text to the screen. -
Give an example of a function that produces a side effect and another function that produces a value.
prompt(" enter your age here!");
console.log(â28â); -
What is control flow?
The procedure how the program executes more than one statement as in a story read from top to bottom. -
What is conditional execution?
To execute a code based on a condition that is met for that code to be executed. -
What kind of keyword do you need to use to invoke conditional execution?
That is the keyword âifâ.
-
What is an expression?
= A fragment of code that produces a value is called an expression. -
What is a binding?
= Binding is a thing provided by JS or catch and hold values. -
What is an environment?
= The collection of bindings and their values that exist at a given time is called an environment. -
What is a function?
= A function is a piece of program wrapped in a value. -
Give an example of a function.
= prompt(âEnter Usernameâ); -
What is a side effect?
= When a statement displays something on the screen or it changes the state of a machine in a way that will affect the statements that come after it is called side effect. -
Give an example of a function that produces a side effect and another function that produces a value.
= prompt(âEnter Usernameâ); *produces a side effect
= console.log(a+b); *produces a value -
What is control flow?
= When codes are executed from top to bottom, left to right is called and control flow. -
What is conditional execution?
= When a program takes the proper branch based on the
situation at hand is called conditional execution.
-
Itâs a programming language based on a combination of one or more values, variables, constants, functions or operators that it is interpreted and computed to produce or return another value.
-
Data binding is used to connect two elements of data together. Binding is the association of a network socket with a local port number and IP address. Name binding is the association of code with an identifier.
-
A collection of bindings and their values that exist at a certain point in time.
-
A piece of code wrapped in a value. It performs a tasks and it returns a value.
-
The alert function that prompts the user with a dialog box along with a message, in which the user can type any value that can eventually be used further down the line.
-
When the scope or interaction with functions are modified and thus returns a value.
-
The prompt function and the print function.
-
Itâs the order where statements, instructions or functions are executed or evaluated.
-
Certain parts of the code are executed only if a certain condition is fulfilled.
10.If, Else If and Else.
Assigment
What is an expression?
_An expression can be anything as values so 1 or âabcâ or a const or a var etc.
What is a binding?
_Binding is associating expressions with values
What is an environment?
_ An environment is a list of statements available, and functions of a script
What is a function?
_A function is a statement of expressions that hold and interacts with other statements to create new ones.
Give an example of a function
_function additionFruits (apples, pears) {
console.log(apples + pears);
};
additionFruits (1, 3)
What is a side effect?
_ A side effect is the changes of state. In our case, .log ( + ) is our side effect to the console to screen out apples values added with pears values.
Give an example of a function that produces a side effect and another function that produces a value.
_function Fruits (aples, pear) {
var aples = 1;
var pear = 3;
};
log(("Total fruities = ") + aples + pear));
function additionFruits (aples, pear) {
var af = aples + pear
if {
af == aples + aples;
log(("Great, here it is: ") + (aples + aples));
};
else {
af !== aples + aples;
log((âBro, you cant mix apples with pearsâ));
};
};
log(additionFruits);
What is control flow?
_A control flow is the numbers of stops the programs makes while running it.
What kind of keyword do you need to use to invoke conditional execution?
_ if, else, elseif
Please if I am not right with my function examples or with any other answers, feel free to comment as I could not see a pdf for answers to this one. Thanks,
- any code that gives value.
- an expression that is saved to console memory.
- a collection of bindings and their values.
- a piece of program wrapped in a value.
- console.log
- showing a dialog box or writing text to the screen
7 <alert(âalert is a function with side effectâ)
console.log(2+4); produces a value - control flow is the order the program is read (top to bottom)
- conditional execution is a branching road in the program where the program takes the proper route based on the situation.
- if
- What is an expression?
A fragment of code that produces a value.
- What is a binding?
A binding or variable is a functionality that JavaScript provides to catch and hold values.
- What is an environment?
A 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.
console.log(Math.max(2, 4));
// â 4
- What is a side effect?
Showing a dialog box or writing text to the screen is a side effect.
- Give an example of a function that produces a side effect and another function that produces a value.
prompt(âEnter passcodeâ);
console.log(Math.min(2, 4) + 100);
// â 102
- 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. This is called conditional flow.
- What is conditional execution?
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.
- What kind of keyword do you need to use to invoke conditional execution?
If () {
âŚ
} else {
âŚ
}
- Is a fragment of code that produces a value, and every expression can contains other expression in order to build complex commands.
- Is a thing created by Javascript to hold and catch values.
- The collection of binding and their values is an enviroment.
- Piece of program wraped in a value.
- console.log; prompt.
- writing text showing to the screen.
- Side Effect example:prompt (" how old are you?");
Value example console.log (4*2); - The order that statemenst or functions are executed.
- When we want to execute a code only if a certain condition holds.
- For example If".
-
An expression is a fragment of code that produces value.
-
A binding is a (second) kind of statement that catches and holds value.
-
An environment is the collection of bindings and their values that exist at a given time.
-
A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.
-
console.log(âhelloâ);
-
A side effect is a statement that can change the internal state of the machine in a way that will affect the statements that come after it.
-
console.log(prompt(âEnter your nameâ));
console.log(1 + 1); -
Control flow is the way statements are executed, which is from top to bottom and from left to right.
-
Conditional execution is an expression when we want to create a âbranching roadâ, where the program takes the âproper branchâ based on the situation at hand.
-
Keyword to invoke conditional execution is
if
.
-
What is an expression?
A. A fragment of code that produces a value is called an expression. -
What is a binding?
A. We have seen how to produce new values from old values, but this does not
change the old values, and the new value has to be immediately used or it will
dissipate again. To catch and hold values, JavaScript provides a thing called a
binding -
What is an environment?
A. The collection of bindings and their values that exist at a given time is called
the environment. -
What is a function?
A. A function is a piece of program wrapped in a value. -
Give an example of a function.
A. Alert function -
What is a side effect?
A.A statement stands on
its 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 could change
the internal state of the machine in a way that will affect the statements that
come after it. These changes are called side effects. -
Give an example of a function that produces a side effect and another function that produces a value.
A. console.log(Math.max(2,4)); -
What is control flow?
A. Statements executed by a program and can be conditional execution, while and do loops. -
What is conditional execution?
A. Program execution based on program taking the branch road on the situation at hand. -
What kind of keyword do you need to use to invoke conditional execution?
A. If, else
- Expresssion: A fragment of code that produces a value.
- Binding: It is a piece of code that holds a value, also known as a variable.
- Environment: A collection of bindings and their values that exist at a point in time.
- Funcition: A piece of program wrapped in a value. The values can be used to run the wrapped program.
- Example of a function: console.log.
- Side effect: Writing text to the screen would be a side effect.
- Example of side effect: console.log writes to the screen. This is a side effect of the function. The Math.max function gives a value instead of a side efffect.
- Control flow: A program executes statements in an order that will produce a value.
- Conditional execution: A series of statements to produce a value may not have a direct route. We could produce a branch to the route depending on what is being input.
- Keyword for conditional statement: If.
1 An expression is any fragment of code that results in a value.
2 A binding, is variable, is named storage for holding a value
3 An environment is the collection of variables that exist at a given time.
4 Functions are a group of codes that can be run by a program to calculate a value.
5 prompt, alert,
6 A side effect is when the code modifies any state, such as printing a screen or reassigning a variable.
7 prompt(âHow old are you?â);
8 Top-down code excuting.
9 if, if else, else
10 if,if else, else