Skip to content

Instantly share code, notes, and snippets.

@spektraldevelopment
Last active September 18, 2018 18:52
Show Gist options
  • Save spektraldevelopment/b2aee870f608efb6de2991a42fdfd097 to your computer and use it in GitHub Desktop.
Save spektraldevelopment/b2aee870f608efb6de2991a42fdfd097 to your computer and use it in GitHub Desktop.
JS: FizzBuzz
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