Created
October 16, 2025 12:24
-
-
Save kenneropia/3bdbdda72d1c01eb7b3eeae23a70c502 to your computer and use it in GitHub Desktop.
fizz_buzz solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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