Skip to content

Instantly share code, notes, and snippets.

@germancutraro
Last active September 2, 2017 19:26
Show Gist options
  • Save germancutraro/756abc27f6a743964a670cab893c8172 to your computer and use it in GitHub Desktop.
Save germancutraro/756abc27f6a743964a670cab893c8172 to your computer and use it in GitHub Desktop.
Fizz Buzz Algorithms in JavaScript by germancutraro
function fizzBuzz (num) {
for (i = 1; i <= num; i++) {
let fizz = i % 3 === 0,
buzz = i % 5 === 0;
console.log(fizz && buzz ? 'fizzBuzz' : fizz ? 'Fizz' : buzz ? 'Buzz' : i);
} // end for loop
}
fizzBuzz(20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment