Guest User

Untitled

a guest
May 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 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 the number is divisible by 3, write "Fizz"
  7. if ( i % 3 === 0 ) {
  8. console.log("Fizz");
  9. if (i % 5 === 0) {
  10. console.log("FizzBuzz");
  11. }
  12. }
  13.  
  14. // if the number is divisible by 5, write "Buzz"
  15. else if ( i % 5 === 0 ) {
  16. console.log("Buzz");
  17. }
  18.  
  19. // otherwise, write just the number
  20. else {
  21. console.log(i);
  22. }
  23. }
Add Comment
Please, Sign In to add comment