variables for numbers Flashcards

1
Q

You can assign a string to a variable. You can also assign a ______.

A

number

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

If a number is enclosed in quotes, it’s a ______.

A

string

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

What kind of operation can be done on a number variable that, in one particular case, can’t be done on a string variable? Answer with a 4-letter word. (It would be a five-letter word in British usage.)

A

math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
What is the value of orderTotal?
var merchTotal = 100;
var shippingCharge = 10;
var orderTotal = merchTotal + shippingCharge;
A

110

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

In a single statement, declare the variable numberAsString and assign the number 3 to it as a string.

A

var numberAsString = “3”;

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

Assign to the variable caseQty, which has already been declared, the value 144.

A

caseQty = 144;

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

In a single statement declare a variable and assign to it the sum of 2 other variables. (You’ve learned only two rules for naming variables so far, so they’re the only ones I’ll hold you to.)

A

var total = cost + profit;

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

var num = “9”;

A

var num = 9;

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

Assign the sum of 2 numbers to a variable, which hasn’t been declared beforehand. (You’ve learned only two rules for naming variables so far, so they’re the only ones I’ll hold you to.)

A

var sum = 1 + 1;

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

In one statement declare a variable. In a second statement assign it the sum of 2 numbers. (You’ve learned only two rules for naming variables so far, so they’re the only ones I’ll hold you to.)

A

var total;

total = 1 + 1;

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

In a single statement declare a variable and assign a number to it. You’ve learned only two rules for naming variables so far—no quotes and no initial number—so they’re the only ones I’ll hold you to. (The timer starts when you click in the answer field.)

A

var topScore = 100;

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

In the first statement declare a variable and assign it a number. In the second statement, change the value of the variable by adding it together with a number.

A
var friends = 30;
friends = friends + 10;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly