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

1 Like

#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”

0 Likes

#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

0 Likes

#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
0 Likes

#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
0 Likes

#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
0 Likes

#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

0 Likes

#410
  1. What is an expression?
    A fragment of code that produces a value is called an expression.
  2. What is a binding?
    To catch and hold values, JavaScript provides a thing called a
    binding, or variable
  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.
    Math.max(2, 4)
  6. What is a side effect?
    If an expression changes the internal state of the machine in a way that will affect the statements that come after it. These changes are called side effects.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    An example of a function that produces a side effect would be one that writes text to the screen or produces a dialog box (1st one would be console.log();, and the latter would be alert();). An example of a function that produces a value would be math.min(4 , 2);
  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.
  9. What is conditional execution?
    Conditional execution is created with the if keyword in JavaScript. In the
    simple case, we want some code to be executed if, and only if, a certain condition
    holds.
  10. What kind of keyword do you need to use to invoke conditional execution?
    if
0 Likes

#411

1.) What is an expression?
A piece of program that return values which may be numeric, string, or logic.

2.) What is a binding?
Binding is a variable that link a value to a variable and
store that value for later use.

3.) What is an environment?
An environment is set of variables and their values as binded
at a given time for later use.

4.) What is a function?
A function is a way of packaging code that does something and then returns the value, it can be called from other parts of your code.

5.) Give an example of a function.
namespace ExampleOfFunction1
{
class compute
{
static int s1, s2, outcome;
public static void add()
{
Console.Write(“Enter 1st serial number.\t”);
s1 = Convert.ToInt32(Console.ReadLine());

        Console.Write("Enter 2nd serial number.\t");
        s2 = Convert.ToInt32(Console.ReadLine());

        outcome = s1 + s2;

        Console.Write("\nAdd = {0}", result);
        Console.ReadLine();
    }
}
class Program // 
{
    static void Main(string[] args)
    {
        compute.add();
    }
}

}
6.) What is a side effect?
Side effect is the return value of a function

7.) Give an example of a function that produces a side effect and another function that produces a value.
Produces side effect:
prompt(“Enter 1st serial number.\t”);
Produces value:
Console.Write("\nAdd = {0}", result);

8.) What is control flow?
This is the order in which statements are executed in a program

9.) What is conditional execution?
This is when a statement’s execution is a function on a certain condition.

10.) What kind of keyword do you need to use to invoke conditional execution?
The “if” keywords is used to invoke conditional execution

0 Likes

#412

[quote=“ivan, post:1, topic:3069”]

  • What is an expression?

A piece of code that produces a value is an expression. It could be written directly, between parentheses, a binary operator applied to two expressions, or a unary operator applied to one.

  • What is a binding?

A variable (aka binding) can be used as an expression that produces the value it holds after it has been defined.

  • What is an environment?

The collection of variables 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.

Math.min is a function.

  • What is a side effect?

In program, this is something that changes the world or the internal program in a way that will alter its output.

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

Showing a dialog box with ‘alert’ is a side effect.
Using Math.max or Math.min will produce a value

  • What is control flow?

Control flow is the order in which our code is executed.

  • What is conditional execution?

One that only executes if the proper condition(s) is/are met.

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

You’d usually use ‘if’ to invoke a conditionally executed line of code.


0 Likes

#413
  1. An expression is a fragment of code that produces a value.
  2. A binding allows you to catch and hold values within code.
  3. The collection of bindings and their values that exist at a given time is an environment.
  4. A function is a piece of program wrapped in a value.
  5. console.log is an example of function.
  6. Showing a dialog box or writing text to the screen.
  7. power and square are examples of functions that produce a value. A function such as makeNoise only produces a side effect.
  8. like a story, JavaScript is interpreted from top to bottom (typically). This is called the control flow
  9. A conditional execution is basically a branch off of the of regular top-to-bottom flow of the control flow.
  10. the if keyword invokes conditional execution
0 Likes

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

  2. What is a binding? A program keep an internal state through a binding or variable.

  3. What is an environment? The values of all variables in the program in a given time.

  4. What is a function? A function is a part of code that returns a value or produces a side effect. A function can be applied to some input values, called arguments of the function.

  5. Give an example of a function. A call to a function is for example:

prompt(“Enter your name”);

A simple source code of a function is:

function MySum(a,b) {
return a+b;
}

  1. What is a side effect? A side effect is a result produced by a function as showing a dialog box 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. A simple function that produces a side effect is
    function myAlert (a) {
    alert(a);
    }

    A simple function that produces a value is
    function myCheck(p1,p2,p3) {
    return p1+p2+p3;
    }

  3. What is control flow? It’s the sequence of execution of a program containing more than one statement: the statements are executed from top to bottom.

  4. What is conditional execution? The sequence of execution can follow a branched road where the program takes the proper branch based on the situation at hand.

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

0 Likes

#415
  1. What is an expression?
    A fragment of code that produces a value.
  2. What is a binding?
    A binding is a variable. Sort of a place holder for a value that can be changed at anytime.
  3. What is an environment?
    A collection of bindings and values that exist at any given time.
  4. What is a function?
    “A piece of a program wrapped in a value” or “A special value that encapsulate a piece of program”
    My words… A small program(s) that are used frequently within other code.
  5. Give and example of a function?
    Prompt, Console.log, Sum, Let, Var.Length, You can write your own Functions to be used later in your code.
  6. What is a side effect?
    Results of code that does not assign or return values. I.E… outputting text, creating a prompt, Formating.
  7. Give an example of a function that produces a side effect and another that produces a value.
    Side effect… Prompt, Console.log
    Value… Var.length, Sum, Math.max, Let
  8. What is control flow?
    The order in which the expressions are executed. Top to bottom, Left to right… But we can use conditional statements to change the flow. " Jump to" different parts of code.
  9. What is conditional execution?
    To set a criteria or “condition” to be met prior to executing the code.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If, while,else,for, else if,switch
0 Likes

#416

0 Likes

#417

Reading Assignment - Binding, Functions and Control Flow

  1. What is an expression?
  2. An expression is a fragment of code that produces a value.

  3. What is a binding?
  4. Bindings are to catch and hold information such as values as variables or constants.

    Statements that can be used as bindings: let, var, const

    Example:
    let num = 24;
    let str = "Text";

  5. What is an environment?
  6. An environment is a collection of bindings and there values at a given time.

  7. What is a function?
  8. A function is a piece of program wrapped in a value. Basically functions are complex bindings.

  9. Give an example of a function.
  10. Example: prompt("Enter something");

  11. What is a side effect?
  12. Side effects are showing up as dialog boxes or writing texts. These are values that can be useful.

  13. Give an example of a function that produces a side effect and another function that produces a value.
  14. Value:
    console.log(Math.max(2, 5, 61) + 1); gives us 62 as a value
    side effect:
    alert ("Hello Ivan"); The argument is showing up on the screen as side effect

  15. What is control flow?
  16. Control flow is the order how statements are executed, from top to bottom.

  17. What is conditional execution?
  18. When a program is following a specific path to execute there expressions(functions) depending of certain conditions, this is called conditional execution.

  19. What kind of keyword do you need to use to invoke conditional execution?
  20. if
0 Likes

#418
  1. A piece of code which resolves to a value.
  2. Saving a value to memory
  3. The current state of the program
  4. An expression which has one of more variables and performs a certain task
  5. addNumbers(5, 2, 4);
  6. Things which happen without your specific direction such as a dialog box
  7. Alert produces a dialog box side effect, if statements produce a Boolean value
  8. Control flow is the order in which the code executes in a program
  9. Conditional execution uses if statements to determine the control flow of the program based on if something is true or not
  10. If is the keyword to invoke conditional execution
0 Likes

#419

An expression is any bit of code which resolves to a value.

A binding is a variable - a value that “grabs ahold” of another value, until given a different value to grab ahold of.

An environment is a collection of values and bindings - preferably coherent!

A function is a set of rules wrapped in a value, which can then be fed additional values (arguments). One example would be the following:

function square(p1) {
   return p1 * p1;
}

Which returns the square of the argument.

A side effect is the result of an expression or statement which isn’t really the end result (i.e. a value), but still might be useful. A pure function maps directly to a value with input. A side effect would be a result of the function without being crucial to the function’s role itself.

For instance:

add_two_bindings(x, y) {
    alert("This is a side effect"); 
    return x + y;
}

The following would simply produce the value:

add_two_bindings(x, y) {
    return x + y;
}

Control flow is the arranged sequence of statements in a program. Programs can make decisions (for instance, using if and else statements). These evaluate whether certain conditions are met and then execute (or ignore) further statements.

0 Likes

#420
  1. What is an expression?
    An expression is a fragment of code that produces a value.

  2. What is a binding?
    A binding is as association of an entity with an identifier. It is provided by JavaScript to catch or hold values.

  3. What is an environment?
    An environment is the collection of bindings and their values that exist at a given time, for example in a program or in a browser.

  4. What is a function?
    A function is a piece of program wrapped in a value, which can be applied in order to run the wrapped program.

  5. Example of a function: Number() is a function which converts a value to a number.

  6. What is a side effect?
    A function can produce a side effect if it modifies some value(s) and thus has an observable effect besides returning a value (the main effect), for example showing a dialog box or writing text to the screen.

  7. Function that produces a side effect: alert()
    Another function that produces a value: console.log()

  8. What is control flow?
    Control flow is is the order in which statements are executed (as if they are a story).

  9. What is conditional execution?
    It is a way to create a branching road, where the program takes the proper branch based on the situation at hand.

  10. What kind of keyword do we need to use to invoke conditional execution?
    if

0 Likes

#421
  1. An expression is a fragment of code which produces a value.
  2. With a binding, we assign a value to a name of binding.
  3. An environment is the collection of bindings and their values which exist at a certain time.
  4. A function takes in values as an input and executes a task.
  5. alert(“Hello World”)
  6. A side effect is any change of the state of the machine, this could be a change which affect statements afterwards or displaying something on the screen.
  7. Side effect:
    alert(“Hello World”)
    returns a value:
    Math.max(0,2)
  8. the order in which code is executed, from top to bottom.
  9. we have conditional execution when the code does execute straight from top to bottom but branches.
  10. if
0 Likes

#422

What is an expression?

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. It can be binary or an expression.

What is a binding?

Bindings catch and hold values. Bindings are like tentacles. They grasp values and do not contain them.

Let, var (variable) and const (constant) can create bindings.

What is an environment?

It’s the collection of a binding and its value. The environment is always loaded with some content i.e. that the mouse interacts with a browser.

What is a function?

Functions are part of a program that are wrapped in a value. It’s a block of code designed to perform a particular task.

Give an example of a function.

I.e. “prompt” opens up a dialog box.

What is a side effect?

Showing a dialog box or writing text to the screen is a side effect. It’s what comes out of a function.

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

Math.max --> value; it gives the biggest of a set of numbers.

Prompt --> side effect; opens the dialogue box

What is control flow?

The way in which statements are executed. Javascript normally executes from top to bottom.

What is conditional execution?

It’s when the execution is not following a straight line but branches. This is created with “if”.

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

“if” and “else”

0 Likes