Below is my code so far. My console.log is printing the array in sequential numbers each time I run the function. I want "fizz" to be printed when count%3===0, which it’s doing, but also adding 3 to the array. I want the array to look like this [1, 2, "fizz", 4, 5, "fizz", ].
var output = [];
var count = 1
function fizzBuzz(){
output.push(count);
count++;
console.log(output);
if (count % 3 == 0){
output.push("fizz");
}
2
Answers
modify your code with this
Not sure what you expect so here are two solutions :