JS_Variables_Quiz_md - brainchildservices/curriculum GitHub Wiki
-
What are variables used for in JavaScript Programs?
A. Storing numbers, dates, or other values
B. Varying randomly
C. Causing high-school algebra flashbacks
D. None of the above
Ans: A
-
Which of the following is not a valid JavaScript variable name?
A. 2names
B. _first_and_last_names
C. FirstAndLast
D. None of the above
Ans: A
-
In the following code, "Mark" is a string. What is the name (answer with 1 word)?
var name = "Mark";
A. Integer
B. Variable
C. Value
D. None of the above
Ans: B
-
What is the keyword that declares a variable in Javascript?
A. Variable
B. int
C. Var
D. String
Ans: C
-
Declare a variable.
Ans: var lastName;
-
Declare a variable without defining it. Then, in a second statement, assign it a string.
Ans: var city;
city = "Boston";
-
In a single statement declare a variable of your choice and assign a string of your choice to it.
Ans: var lakeName = "Huron";
-
What is the value of orderTotal?
var merchTotal = 100;
var shippingCharge = 10;
var orderTotal = merchTotal + shippingCharge;
Ans:110
-
In a single statement declare a variable and assign a number to it.
Ans: var topScore = 100;
-
Display the sum of 5 + 10, using two variables: x and y.
var x = ---;
var y = 10;
document.getElementById("demo").innerHTML = x ? y;
-
Create a variable called z, assign x + y to it, and display the result in an alert box.
var x = 5;
var y = 10;
-- - = x + y;
---- (z);