Created
January 18, 2017 07:37
-
-
Save sghall/441e2ab9bb45934822b1d4c769fe1e14 to your computer and use it in GitHub Desktop.
Fizz Buzz in JavaScript
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
function fizzBuzz(num) { | |
for (let i = 1; i <= num; i++) { | |
const fizz = i % 3 === 0 ? 'Fizz': ''; | |
const buzz = i % 5 === 0 ? 'Buzz': ''; | |
console.log(fizz || buzz ? fizz + buzz: i) | |
} | |
}; | |
console.log(fizzBuzz(100)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment