Skip to content

Instantly share code, notes, and snippets.

@nailkhasipov
Last active January 4, 2017 05:44
Show Gist options
  • Save nailkhasipov/b7cfb86f9f55e0fb4af1498043ed64a4 to your computer and use it in GitHub Desktop.
Save nailkhasipov/b7cfb86f9f55e0fb4af1498043ed64a4 to your computer and use it in GitHub Desktop.
/*
Write a program that uses console.log to print all the numbers from 1 to 100,
with two exceptions. For numbers divisible by 3, print "Fizz" instead of the number,
and for numbers divisible by 5 (and not 3), print "Buzz" instead.”
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
*/
for (var n = 1; n <= 100; n++) {
var output = "";
if (n % 3 == 0)
output += "Fizz";
if (n % 5 == 0)
output += "Buzz";
console.log(output || n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment