Created
November 22, 2018 21:54
-
-
Save kunokdev/897e92ed2bccca2da9e850f8ad18329f to your computer and use it in GitHub Desktop.
FizzBuzz created by kunokdev - https://repl.it/@kunokdev/FizzBuzz
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 iterationCreator(num, valueFactory, actionFactory){ | |
for (let i = 1; i <= num; i++) { | |
actionFactory(valueFactory(i)) | |
} | |
} | |
function fizzBuzz(num){ | |
if (num % 3 === 0 && num % 5 === 0) return 'FizzBuzz' | |
if (num % 3 === 0) return 'Fizz' | |
if (num % 5 === 0) return 'Buzz' | |
return num | |
} | |
iterationCreator(30, fizzBuzz, console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment