Last active
September 18, 2018 18:52
-
-
Save spektraldevelopment/b2aee870f608efb6de2991a42fdfd097 to your computer and use it in GitHub Desktop.
JS: FizzBuzz
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 fizzBuzz(n) { | |
for(let i = 1; i <= n; i++) { | |
//Is the number a multiple of 3 and 5 | |
if(i % 3 === 0 && i % 5 === 0) { | |
console.log('fizzBuzz'); | |
} else if (i % 3 === 0) { | |
//Is the number a multiple of 3 | |
console.log('fizz'); | |
} else if (i % 5 === 0) { | |
//Is the number a multiple of 5 | |
console.log('buzz'); | |
} else { | |
console.log(i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment