Guest User

Untitled

a guest
May 22nd, 2018
78
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 the number is divisible by 3, write "Fizz"
  7. if ( i % 3 === 0 ) {
  8. console.log("Fizz");
  9. if ( i % 5 === 0) {
  10. ("Fizz".replace("Fizz","FizzBuzz"));
  11. }
  12.  
  13. // if the number is divisible by 5, write "Buzz"
  14. else if (i % 5 === 0) {
  15. console.log("Buzz");
  16. }
  17. // otherwise, write just the number
  18. else {
  19. console.log(i);
  20. }
  21. }
Add Comment
Please, Sign In to add comment