Created
March 19, 2019 20:36
-
-
Save marsrvr/59c8e4ba783c5970a38b897e991d1f2e to your computer and use it in GitHub Desktop.
Ivan on Tech Academy Smart Contract Programming course, Eloquent JavaScript Chapter 2, Exercise 2: "fizz buzz"
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 fizzbuz(target) { | |
for (var i = 1; i <= target; i++) { | |
linestr = i; | |
if (i%3 == 0) { | |
linestr = 'fizz'; | |
if (i%5 == 0){ | |
linestr = 'fizzbuzz'; | |
} | |
} else if (i%5 == 0) { | |
linestr = 'buzz'; | |
} | |
console.log(linestr) | |
} | |
return 'done.' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Print number. "fizz" if divisible by 3. "buzz" if divisible by 5.