console.log(Math.max(16,24));
// 24
thank you
console.log(Math.max(16,24));
// 24
thank you
A: A fragment of code that produces a value
A: A way to catch and hold values in javascript such as keeping an internal state or remembering things
A:The collection of bindings and their values that exist at a given time
A: A function is a piece of program wrapped in a value
A: Making a value work with a function is like when you are lookig for a certain product on amazon you ask the âsearchâ bar to find a âcarseatâ
A: Showing a dialog box or writing text to the screen
A: wWhen looking for a value of a car you might look for the price range you can afford based on how much you have so the min. amount or the max. would be based off of the amount you have â$5000â
min $500 max $5000 my budget is $3000
A:When your program contains more than one statement, the statements are
executed as if they are a story, from top to bottom
A: A branching road, where the program takes the proper branch based on the
situation at hand
A: The if keyword executes or skips a statement depending on the value of
a Boolean expression
Thanks for let me know all my miss-understandings. This concepts are a bit abstract for me, can you give me a very kinder-garden example of it.
I think I understand that this part of the code is not showing what i intent to ? So there is no side effect.
So I get that a function is a pice of code enclosing in a value.
Thanks for your help
have a good one !
Any piece of code that produces a value, including values.
Similar to a variable, a binding binds a value to itself. It effectively stores that value within itself, acting as a reference to said value.
An environment is a collection of all bindings and their values. Even if no specific binding has been created, there is still a collection of default/standard bindings found in an environment.
A function is a procedure used to execute code, or find a value, using the instructions provided within the function.
function sum(a,b) {return a + b};
A side effect is an observable effect, besides a returned value, that occurs when executing programming instructions. Example: a pop up window.
a. prompt(âEnter Passwordâ) or alert(âwazzupâ)
b. Math.max(2,5,8,14,35);
The order in which statements are executed. They are executed in the chronological order in which they are written.
With conditional executions certain parameters need to be met before the code is executed. Example: only if this happens, execute the code.
if
Hi @kmilo_Mart!
Yes, they are abstract⌠Iâll do my bestâŚ
Exactly rightâŚand the functions that create these side effects are:
alert("Print my side effect in the pop-up box!");
console.log("Display my side effect in the console!");
Exactly rightâŚ
function plus(x, y) {
return x + y;
}
This function returns the sum of x + y (a value) to wherever IN THE PROGRAM the function was called from. It is not something that happens OUTSIDE OF THE PROGRAM (like printing to the console).
So I get that a function is a pice of code enclosing in a value.
YesâŚthis description of a function is pretty abstract to be honest, but by a piece of code (or âmini-programâ) enclosed within a value I think the author means that when the function executes it returns a value, so in the end it equates to a value⌠at least thatâs how I understand this definition!
To be honest, itâs probably easier first of all to define these different programming concepts with an actual visual example of the code. Then when you can visualise that from memory, you can start to think about what the code really achieves.
I hope that makes things even clearer!
Hi @Bifin!
Just a couple of things to clarify, reallyâŚ
Example Side Effect: The function Math.max takes any amount of number arguments and gives
back the greatest.
console.log(Math.max(2, 4));
// â 4
The actual function that produces a value is Math.max(2, 4)
The console.log()
that itâs wrapped in, is a function that produces a side effect, the side effect being printing the highest number (4) to the console.
Example value function:
console.log(Math.min(2, 4) + 100);
// â 102
Here, the actual function that produces a value isâMath.min(2, 4)
The console.log( + 100)
that itâs wrapped in, is the function that produces a side effect, the side effect being printing the lowest number + 100 (102) to the console.
function mult(a,b){
return a*b;
}
console.log(mult(2,2));
//4
//side effect
alert("hello")
//function
return a*b;
}
console.log(mult(2,2));
//4
for(){
}
Side effect prompt(âEnter passcodeâ);
Value prompt console.log(Math.max(2, 4));
// â 4
A fragment of code that produces a value is called an expression.
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 program wrapped in a value.
let red = 16;
console.log(âredâ);
Showing a dialog box or writing text to the screen is a side effect.
console.log(Math.max(2, 4, 6, 8, 10));
alert(âHello worldâ);
When your program contains more than one statement, the statements are
executed as if they are a story, from top to bottom.
If we create a code that is branched depending on the condition that code will be an example of a conditional execution.
if
10. What kind of keyword do you need to use to invoke conditional execution?
for(){ }
Hello sir, a for is not exactly a conditional statement. The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement (usually a block statement) to be executed in the loop.
Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run.
Here a simple website that can help you to understand it even better: JAVASCRIPT CONDITIONALS
Hope this gives you a clear view of the subject, keep learning!
If you have any doubt, please let us know so we can help you!
Carlos Z.
What is an expression?
An expression is a fragment of code that produces a value. It corresponds to a sentence fragment. It ends with a semi-colon.
What is a binding?
Binding is also called variable.
What is an environment?
Environment is a collection of variables and their values that exist at a given time.
What is a function?
Function is a piece of program wrapped in a value.
Give an example of a function.
Example: alert(âGreetingsâ);
What is a side effect?
Side effects are the internal changes that affect the statements that come after it.
Give an example of a function that produces a side effect and another function that produces a value.
Example of value: math.max produces a value
Example of a function with side effect
âConfirmâ function produces an extra window
What is control flow?
Control flow is when your program contains more than one statement, the statements are executed as if they are a story, from top to bottom.
What is conditional execution?
A conditional execution is a control flow where we choose between two different routes based on a Boolean value. Itâs a âif
Example: var age= 17;
If (age<18)
Console.log(âYou are an adultâ);
What kind of keyword do you need to use to invoke conditional execution?
If, else, switch
An expression is any kind of code that results in a value.
A binding or variable catches and holds values.
The collection of bindings and their values is called the environment.
A function is a piece of program wrapped in a value.
prompt(âEnter passcodeâ);
A side effect is where a functions does something other than return a value.
prompt(âEnter passcodeâ); prompts dialogue box
console.log(Math.max2, 4); produces a value
The order in which statements are executed, left -> right, top -> bottom.
When the program takes the proper branch based on the situation at hand.
If
ohh that makes sense, I appreciate it!
Some really good answers here, @Emmerich! I can see youâve really understood the concepts as youâve described things using your own words.
Keep up the great work!
1. What is an expression?
Anything that produces a value is an expression in JavaScript.
2. What is a binding?
To catch and hold values, JavaScript provides a thing called a binding, or variable. After a binding has been defined, its name can be used as an expression.
3. What is an environment?
The collection of bindings and their values that exist at a given time.
4. What is a function?
A function is a piece of program wrapped in a value.
5. Give an example of a function.
prompt(âType a valueâ);
6. What is a side effect?
Showing a dialog box, writing text to the screen or change the internal state of the machine in a way that will affect the statements that come after it. 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.
alert(âBitcoin is pumpingâ); - produces a side effect
Math.max(x , y); - produces a value
8. What is control flow?
When a program contains more than one statement, control flow is the order in which the computer will execute the statements in the script.
9. What is conditional execution?
Conditional execution creates a branching road, where the program takes the proper branch based on certain conditions, assisting in decision making.
10. What kind of keyword do you need to use to invoke conditional execution?
We can use the if keyword to invoke a conditional execution, and together with else, to create two separate, alternative execution paths.