Part 1- A Smarter Way to Learn JavaScript Flashcards

1
Q

What’s the code to declare a variable?

A

var variableName = “text string defining variable”;

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

Do you have to assign a value to a variable when you declare it?

A

No. You can assign a value to it later.

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

When you are assigning a new value to a variable that has already been declared, do you have to use var?

A

No. You only use var when you are declaring a variable

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

Can you use a number for a variable name?

A

No. Your variable name can have numbers in it, but it cannot start with a number. It must start with a letter, or $ or _

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

A number cannot be used in equations if it has what?

A

Quotation marks around it, because then it would be a string.

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

Can a variable be used in calculating its own new value?

A

Yes, such as:
var x = 90;
x = x + 1;

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

What’s wrong with this variable? var propertiesOf”It”?

A

It has quotes. A variable cannot have quotes.

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

How do you tell is something is a variable? (list two things)

A

*it’s not a JavaScript keyword, like alert

*it’s an alphabet letter or word

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

Are variables case sensitive?

A

Yes, variables are case sensitive.

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

Which characters can be in a variable?

A

*letters
*numbers (though not at the beginning of the variable name)
*dollar sign
*underscore

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

Can a variable contain a space?

A

No. Variables cannot contain a space.

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

Can a variable contain a JS keyword as part of the variable?

A

Yes. You could use myAlert for example, but not just alert.

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

What does this operator do and what’s it called?
%

A

*Modulus
*returns the remainder of a division statement

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

Incrementors after the variable

A

When the ++ comes afterwards…
x = y++
…then incrementing happens after the assignment of y’s value to x. So the X gets left out of the increase:

1) x becomes what y is
2) y is then incremented

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

Incrementors before the variable

A

When the ++ comes before…
x = ++y
…then incrementing happens before the assignment, so the first variable shares the wealth.

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

Code the short form of x = x + 1;

A

x++;

17
Q

What is x++; short for?

A

x = x + 1;

18
Q

What are these called? ++ –

A

Increment and Decrement Operators

19
Q

What do you call ++ or - - when they come at the end of the variable?

A

Postfix Increment and Decrement Operators

20
Q

What do you call ++ or – when they come before the variable?

A

Prefix Increment and Decrement Operators