Section 3.7. Questions


3.7. Questions

  1. In the following, add parentheses to the expression so that it evaluates to 8:

  2. var valA = 37; var valB = 3; var valC = 18; var resultOfComp = valA - valB % 3 / 2 * 4 + valC - 3;

  3. Using a switch statement, test an expression for a value of one, two, or three, and set a variable to OK if the expression is one or two; OK2 if the expression is three; and NONE if it doesn't match any.

  4. You have three variables, varOne, varTwo, and varThree. How would you test all three such that a block of code is processed only if varOne is 33, varTwo is less than or equal to 100, but varThree is greater than 0?

  5. Execute a loop and print out every number between 10 and 20.

  6. Now do the same counting backward.

Answers are provided in the appendix.




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net