Guest

Untitled

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 307  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. // Add an else statement in case the number is divisible by 5.
  2.  
  3. // for the numbers 1 through 20,
  4. for (i=1; i<=20; i++) {
  5.  
  6.    // if the number is divisible by both 3 and 5, write "FizzBuzz"
  7.   if ( i % 3 === 0 && i % 5 === 0) {
  8.       console.log("FizzBuzz");
  9.   }
  10.   // if the number is divisible by 3, write "Fizz"
  11.   else if ( i % 3 === 0 ) {
  12.     console.log("Fizz");
  13.   }
  14.  
  15.   // if the number is divisible by 5, write "Buzz"
  16.   else if (i % 5 === 0 ){
  17.     console.log("Buzz");
  18.   }
  19.  
  20.   // otherwise, write just the number
  21.   else {
  22.     console.log(i);
  23.   }
  24. }