Lesson 14: Reading Assignment: Binding, Functions and Control Flow
Questions:
-
What is an expression?
An expression is a fragment of code that produces a value. -
What is a binding?
A binding is a reference to a value indicated by the word “let” or “var” at the beginning of an expression. The word “let” or “var” is always followed by the “name” of the binding and is given a “value” through the operator “=” and “an expression”. -
What is an environment?
An environment is a collection of bindings and their values. -
What is a function?
A function is a piece of program wrapped in a value. -
Give an example of a function.
Prompt(“enter age”); -
What is a side effect?
A side effect is 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 name”);
console.log(Math.max(2, 4));
-
What is control flow?
Control flow is the execution path in a program when the program contains more than one statement. Multiple statements in a program are always executed from top to bottom.
- What is conditional execution? What kind of keyword do you need to use to invoke conditional execution?
Conditional execution is created with the “if” word in JavaScript. It simply conditions the function to execute the code if, and only if, a certain condition (or conditions) is (are) met.
Keywords used for conditional execution are: “if” and “else”.