Guest User

Untitled

a guest
May 20th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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 (i%3===0)
  7. if (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. }
Add Comment
Please, Sign In to add comment