Created
September 20, 2019 14:04
-
-
Save giovanniantonaccio/f348a0691f77106c0e9cbd761483e0e2 to your computer and use it in GitHub Desktop.
FizzBuzz algorithm
This file contains 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
/** | |
* FizzBuzz algorithm | |
*/ | |
function checkMultiples(n) { | |
let result = ""; | |
result = n % 3 === 0 ? "Fizz" : result; | |
result = n % 5 === 0 ? result + "Buzz" : result; | |
return result !== "" ? result : n; | |
} | |
for (i = 1; i <= 100; i++) { | |
console.log(checkMultiples(i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment