Module 07 - Variables Flashcards

1
Q

What are the three main actions that can take place in your code when you are defining your own variables?

A
  1. Declaring a variable
  2. Assigning a value to a variable
  3. Using a variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is passed-by-value?

A

When you pass a variable to a function, you’re passing a copy of its value, not the original variable itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the common mistakes when working w/ functions?

A
  • Forgetting to return a value
  • Forgetting to assign the result
  • Returning early unintentionally
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is: x–;?

A

x - 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is: x++;?

A

x + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is: x += 5;?

A

x= x + 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is: x -= 8;?

A

-=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is: x *= 10;?

A

*=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is: x /= 4;?

A

/=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is toggle?

A

Means to switch back and forth between states

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is round()?

A

Calculates the integer closest to a number.

For example, round(133.8) returns the value 134.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is dist()?

A

Calculates the distance 2 (x,y) coordinate positions on the canvas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is constrain()?

A

Guarantees a value between the range provided by the second and third arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a return statement?

A

A return statement in a function will immediately return to the point at which the function was called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is this what a typical setup for a return function looks like?

function myFunction(…) {
let result;
// code that computes result
return result;
}

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly