'javascript ( while loop ) [closed]

hi everyone am fairly new to javascript , so i wrote this fizzbuzz challenge but somehow it wouldn't run i don't know what to do , thanks and here's the code :

var output = []
var count =1;

function fizzBuzz(){
  while(count<=100){
    if (count%3===0 && count%5===0){
     output.push("fizzbuzz");
    }else if (count%3===0){
      output.push("fizz");
    }else if (count%5===0){
      output.push("buzz");
    }else {
      output.push(count);
    }
    count++;
  }
  console.log(output);
}


Solution 1:[1]

i would have used a for loop there, even tho that would work fine, you didnt call the function. add fizzBuzz(); at the bottom

Solution 2:[2]

var output = [];

function fizzBuzz(){
  for(var i=0; i<100; i++){
    if (i%3===0 && i%5===0){
     output.push("fizzbuzz");
    }else if (i%3===0){
      output.push("fizz");
    }else if (i%5===0){
      output.push("buzz");
    }else {
      output.push(i);
    }
    console.log(output);
  }
}

fizzBuzz();

for the while loop

that way you dont need a count variable and its much cleaner

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 skep_sickomode
Solution 2 skep_sickomode