Skip to content

Instantly share code, notes, and snippets.

@kenneropia
Created October 16, 2025 12:24
Show Gist options
  • Select an option

  • Save kenneropia/3bdbdda72d1c01eb7b3eeae23a70c502 to your computer and use it in GitHub Desktop.

Select an option

Save kenneropia/3bdbdda72d1c01eb7b3eeae23a70c502 to your computer and use it in GitHub Desktop.
fizz_buzz solution
function fizzbuzzArray() {
const result = [];
for (let i = 1; i <= 100; i++) {
if (i % 15 === 0) { // 15 is LCM of 3 and 5
result.push("FizzBuzz");
} else if (i % 3 === 0) {
result.push("Fizz");
} else if (i % 5 === 0) {
result.push("Buzz");
} else {
result.push(i.toString());
}
}
return result;
}
console.log(fizzbuzzArray().join(', '));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment