Skip to content

Instantly share code, notes, and snippets.

@htkcodes
Created November 23, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htkcodes/828c4a836ddbbc8a0dc57b0af728b812 to your computer and use it in GitHub Desktop.
Save htkcodes/828c4a836ddbbc8a0dc57b0af728b812 to your computer and use it in GitHub Desktop.
/*jshint esversion: 6 */
/*
Write a algorithm that prints the numbers from 1 to n. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”
*/
fizz(10);
function fizz(number) {
for (let z = 1; z < number; z++) {
0 === z % 15 ? console.log("FizzBuzz"): 0 === z % 3 ? console.log("Fizz"):
0 === z % 5 ? console.log("Buzz"): console.log(z);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment