Last active
January 4, 2017 05:44
-
-
Save nailkhasipov/b7cfb86f9f55e0fb4af1498043ed64a4 to your computer and use it in GitHub Desktop.
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
/* | |
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