var fizzBuzz = function (n) {
let arrayResult = [];
for (let i = 1; i <= n; i++) {
if (i % 3 === 0 && i % 5 === 0) {
arrayResult.push("FizzBuzz");
} else if (i % 3 === 0) {
arrayResult.push("Fizz");
} else if (i % 5 === 0) {
arrayResult.push("Buzz");
} else {
arrayResult.push(i);
}
}
return arrayResult;
};
console.log(fizzBuzz(5));
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
Another implementation