Advertisement
Czopski

FizzBuzz

Feb 8th, 2023
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // fizzbuzz
  3.  
  4. var fizzBuzzArray = [];
  5.  
  6.  
  7. for(let i = 1; i < 101; i++){
  8.    
  9.     if (i % 3 && i % 5){
  10.         fizzBuzzArray.push(i);
  11.     }
  12.     else if (i % 5){
  13.         fizzBuzzArray.push("Fizz");
  14.     }
  15.     else if (i %3){
  16.         fizzBuzzArray.push("Buzz");
  17.     }
  18.     else{
  19.         fizzBuzzArray.push("FizzBuzz");
  20.     }
  21. }
  22.  
  23. alert(fizzBuzzArray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement