JS_Variables_Quiz_md - brainchildservices/curriculum GitHub Wiki

  1. 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

  2. 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

  3. 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

  4. What is the keyword that declares a variable in Javascript?

    A. Variable

    B. int

    C. Var

    D. String

    Ans: C

  5. Declare a variable.

    Ans: var lastName;

  6. Declare a variable without defining it. Then, in a second statement, assign it a string.

    Ans: var city;

    city = "Boston";

  7. In a single statement declare a variable of your choice and assign a string of your choice to it.

    Ans: var lakeName = "Huron";

  8. What is the value of orderTotal?

    var merchTotal = 100;

    var shippingCharge = 10;

    var orderTotal = merchTotal + shippingCharge;

    Ans:110

  9. In a single statement declare a variable and assign a number to it.

    Ans: var topScore = 100;

  10. Display the sum of 5 + 10, using two variables: x and y.

    var x = ---;

    var y = 10;

    document.getElementById("demo").innerHTML = x ? y;

  11. 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);