Created
August 8, 2017 22:25
-
-
Save fdjones/725f6fa5a6ec112bfd6171e2de7f4cec 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
function isDivisibleByY(n, y) { | |
return n % y === 0; // returns true or false | |
} | |
function createNewArray(n) { | |
return Array.from(Array(n).keys()).map(i => ++i) | |
} | |
function print(string) { | |
console.log(string); | |
} | |
createNewArray(100).forEach(function(elem) { | |
console.log(elem); | |
if(isDivisibleByY(elem, 3) && isDivisibleByY(elem, 5)) { | |
print('Fizz Buzz'); | |
} | |
else if(isDivisibleByY(elem, 3)) { | |
print('Fizz'); | |
} | |
else if(isDivisibleByY(elem, 5)) { | |
print('Buzz'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment