kingvlad

FizzBuzz challenge

Sep 7th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var output = [];
  2. var count = 1;
  3.  
  4. function fizzbuzz() {
  5. while (count <=100) {
  6.  
  7. if (count % 3 === 0 && count % 5 ===0) {
  8. output.push("fizzbuzz");
  9. }
  10. else if (count % 3 ===0) {
  11. output.push("fizz");
  12. } else if (count % 5 ===0) {
  13. output.push("buzz");
  14. }
  15. else {
  16. output.push(count);
  17. }
  18. count++;
  19. console.log(output);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment