variables for numbers Flashcards
You can assign a string to a variable. You can also assign a ______.
number
If a number is enclosed in quotes, it’s a ______.
string
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.)
math
What is the value of orderTotal? var merchTotal = 100; var shippingCharge = 10; var orderTotal = merchTotal + shippingCharge;
110
In a single statement, declare the variable numberAsString and assign the number 3 to it as a string.
var numberAsString = “3”;
Assign to the variable caseQty, which has already been declared, the value 144.
caseQty = 144;
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.)
var total = cost + profit;
var num = “9”;
var num = 9;
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.)
var sum = 1 + 1;
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.)
var total;
total = 1 + 1;
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.)
var topScore = 100;
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.
var friends = 30; friends = friends + 10;