Part 1

  1. Predict what the pop-up window will say after the following code executes:

    var a = 5;
    var b = 7;
    if (a > b)
    {
       alert("a is bigger");
    }
    else
    {
       alert("b is bigger");
    }
  2. Answer: The variables a and b are assigned to 5 and 7, respectively. Since 5 is not bigger than 7, then a is not bigger than be. Therefore, the second alert function occurs, and an alert appears with the text "b is bigger".

  3. Consider the following variable assignments:

    a = 100;
    b = 75;
    c = 25;
    d = 1;
    e = "Donald"
    f = "Duck"
    g = "10"
    h = "75"

    What is the result of the following operations or conditions (remember, operations will result in a string or a number, conditions will be true or false). Identify if the output is a string, a number, or a Boolean value:

    1. a + b
      Result: 175 (number)
    2. a % b
      Result: 25 (number)
    3. e + f
      Result: DonaldDuck (string)
    4. e + g
      Result: Donald10 (string)
    5. c * d
      Result: 25 (number)
    6. g + h
      Result: 1075 (string)
    7. f + g
      Result: Duck10 (string)
    8. d + h
      Result: 175 (string)
    9. ((b / c) < a)
      Result: true (Boolean)
    10. ((a % b) == c)
      Result: true (Boolean)
    11. ((c > a) || (b < a))
      Result: true (Boolean)
    12. (h == b)
      Result: true (Boolean)