Chapter 3

  1. The solution is:

  2. var resultOfComp = (valA - valB) % 3 / 2 * (4 + valC) - 3;
  3. The solution is:

  4. switch(val) {
       case 'one','two' : 
         result = 'OK';
         break;
       case 'three' :
         result = 'OK2';
         break;
       default :
         result = 'NONE';
    }
  5. The solution is:

  6. if ((varOne == 33) && (varTwo <= 100) && (varThree > 0))...
  7. and 5. In for loops, you don’t have to start at 0 or 1, and you also don’t have to increment the number. Here’s how to count upward between 10 and 20:

  8. for (var i = 11; i < 20; i++) {
      document.writeln(i + "<br />");
    }
  9. And here’s how to reverse the count:

  10. for (var i = 19; i > 10; i--) {
      document.writeln(i + "<br />");
    }

Get Learning JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.