Guest User

Untitled

a guest
May 22nd, 2018
65
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 && i % 5 == 0)
  7. {
  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. // if the number is divisible by 5, write "Buzz"
  15. else if ( i % 5 === 0)
  16. {
  17. console.log("Buzz")
  18. }
  19. // otherwise, write just the number
  20. else {
  21. console.log(i);
  22. }
  23. }
Add Comment
Please, Sign In to add comment