Module 07 - Variables Flashcards
What are the three main actions that can take place in your code when you are defining your own variables?
- Declaring a variable
- Assigning a value to a variable
- Using a variable
What is passed-by-value?
When you pass a variable to a function, you’re passing a copy of its value, not the original variable itself.
What are the common mistakes when working w/ functions?
- Forgetting to return a value
- Forgetting to assign the result
- Returning early unintentionally
What is: x–;?
x - 1
What is: x++;?
x + 1
What is: x += 5;?
x= x + 5
What is: x -= 8;?
-=
What is: x *= 10;?
*=
What is: x /= 4;?
/=
What is toggle?
Means to switch back and forth between states
What is round()?
Calculates the integer closest to a number.
For example, round(133.8) returns the value 134.
What is dist()?
Calculates the distance 2 (x,y) coordinate positions on the canvas
What is constrain()?
Guarantees a value between the range provided by the second and third arguments
What is a return statement?
A return statement in a function will immediately return to the point at which the function was called
Is this what a typical setup for a return function looks like?
function myFunction(…) {
let result;
// code that computes result
return result;
}
True