Binding, Functions and Control Flow - Reading Assignment


#403

1. What is an expression?
Expressions are the smallest literal syntax of coding; using values, variables, and operators, which computes to a value. As a programmer 9/10 of your errors will be made here due to typing errors, it’s good to use a program code validator like http://www.jslint.com/ to ensure that you avoid such errors. When expressions are used correctly they will be able to execute and be evaluated by the computer, once this happens they have become statements.

2. What is a binding?
The simplest way to think of binding is associating something that’s easy to remember with something that is not easy to remember, in this way a programer can write code with a narrative that is self-explaining to other programers. The key concept for this attribute of Javascript is that it can be done without having to give thought to the value of the object that is being bound, this makes it much easier to program than other languages without such “human friendly” quality.

3. What is an environment?
In Javascript you will be able to have access to use built in programs called functions which give you information about the computer, that the program is running on. You can also build your own custom set of bindings which will build the environment for your program to run at it’s best.

4. What is a function?
A function is a built in program of the language, Javascript has it’s own set of functions which we install through the bundle and allow us to get information about the computer the program is running on.

5. Give an example of a function.
eval(“x * y”) - Evaluates a string and executes it as if it was script code

6. What is a side effect?
When or statements is executed and it has an affect on changing something in the UI or on the computer itself it is considered to be a “side effect”. This is the main purpose of code is to produce a “side effect” that provides value to the user.

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

eval(“alert(“this is a side effect”);”);

function myFunction() {
var x = 10;
var y = 20;
}

8. What is control flow?
This is the direction of how the Javasript emulator reads your code step by step, in this case it is left to right and down, as we type.

9. What is conditional execution?
When a programer wants to have the code so something only when certain conditions are correct, or not correct. If the person for instance types in an email address but no such address exists, the programmer can code an “if statement” which will verify that the email is correct and if it is not a message can be relayed to the user that the email is incorrect.

10. What kind of keyword do you need to use to invoke conditional execution?
If - the if statement is used for conditional executions


#404
  • What is an expression?
    It is a sequence of code that produces a value.

  • What is a binding?
    It is a sequence of code that is used to catch and hold values.

  • What is an environment?
    It is the collective of bindings and their values that exist at a given time.

  • What is a function?
    It is a piece of code wrapped in a value.

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

  • What is a side effect?
    It is an expression that changes the internal state of the machine and the statements that come after it.

  • Give an example of a function that produces a side effect and another function that produces a value.
    Console.log(Math.max(3, 9));
    // → 9

    Console.log(Math.min(3, 9) + 1000);
    // → 1003

  • What is control flow?
    The chronological order of statements in a program from top to bottom.

  • What is conditional execution?
    This allows the program to follow a branch based on the current situation.

  • What kind of keyword do you need to use to invoke conditional execution?
    The keyword is “if”


#405

1/. What is an expression? A fragment of code that produces a value.
2/. What is a binding? A Variable
3/.What is an environment? The collection of bindings and their values that exist at a given time in a program is called the environment.
4/.What is function? A piece of a program wrapped in a value.
5/. Give an example of a function.
prompt (“What is your favourite colour?”);
6/.What is a side effect? Showing a dialog box or writing text to the screen is a side effect.
7/.Function side effect: prompt
Function value: Math.max
8/.What is control flow?
When a program executes statements as if they are a story from top to bottom.
9/. What is a conditional execution?
If you do not want the program to flow in straight line but what it to branch off in a different direction based on the situation at hand.
10/. What kind of keyword do you need to use to invoke conditional execution?
if


#406

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

2.What is a binding?
Binding is nothing but variable.Word var and cost can be used to create bindings.

3.What is an environment?
The collection of bindings and their values that exist at a given time is called the enviornment.

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 Password”)

Prompt is a function and inside paranthesis is the argument.

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.
alert(“side effect”) - produces a side effect.
console.log(2+4)- produces a value.

8.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.

10.What is conditional execution?
where the program takes the proper branch based on the situation at hand. This is called conditional execution.

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

#407

Programming

What is an expression?
-An expression is a piece of code that returns a value

What is a binding?
-A binding is a value or string set to a variable

What is an environment?
-An environment is all of the bindings that have been made within a program.

What is a function?
-A function is a program wrapped in a value

Give an example of a function.

  1. alert(“Wassup wassup wasup”);

What is a side effect?
-A side effect is an expression produced by a function, meaning the displayed screen laid in front of the user will change in some way or form

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

  1. prompt(“Enter Password”); is a function that produces a side effect which requires you fill in a box
  2. -console.log(2+2); is a function that produces no side effect, though produces a value.
    -console.log (Math.max(5, 10) + 100); outputs a value of 110
    -console.log(Math.min(3, 10) + 100); outputs a value of 103
    -console.log(ab* abs * abby); produces a value of 6 if let ab = 1, abs = 2, abby = 3;
    -console.log(AJ + " " + Ocean); produces a value of “Sup Dog” if var AJ = “Sup” and var Ocean = “Dog”

What is control flow?
-Control flow is the order in which a program will execute the code.

What is conditional execution?
-It an execution that allows the program to behave differently based on different information being
entered or manipulated by the user

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

  1. If
  2. else

#408
  1. A fragment of code that produces a value is called an expression
  2. A binding is when a variable holds a value but doesn’t change the old value.
  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: function myFunc(theObject)
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Side effect: prompt(“Enter passcode”) function: console.log(Math.min(2, 4) + 100);
  8. Control flow happens when 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 is basically an if statement that executes codes if a certain condition is met
  10. An “if” keyword

#409
  1. What is an expression?
    Every value that is written literally is an expression.

  2. What is a binding?
    Binding is a way to keep a program’s internal state by catching and holding values with the use of keywords such as let.

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

  4. What is a function?
    A wrapped section that performs a specific task.

  5. Give an example of a function.
    function ivanOnTech(x1, x2) {
    return x1 + x2;
    }

  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.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log(firstAccount);
    var firstAccount = accounts[0];

  8. What is control flow?
    It is the direction of execution of code in JavaScript which happens in a top down approach.

  9. What is conditional execution?
    Conditional Execution is a branch in the control flow’s execution, where JavaScript picks a branch depending if the conditions that are present.

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