Created
March 29, 2021 04:39
-
-
Save amculin/9543e682528435cebc1c8a44b6935e22 to your computer and use it in GitHub Desktop.
FizzBuzz Challenge using JS
This file contains 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
function fizz_buzz(start, last) | |
{ | |
var i; | |
for (i = start; i <= last; i++) { | |
var isFizz = i % 3 == 0; | |
var isBuzz = i % 5 == 0; | |
var string = ''; | |
if (isFizz) | |
string += "Fizz"; | |
if (isBuzz) | |
string += "Buzz"; | |
if (! isFizz && ! isBuzz) | |
string += i; | |
console.log(string); | |
} | |
} | |
fizz_buzz(1, 30); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment