Created
June 19, 2017 21:49
-
-
Save viniazvd/4d7843a360eee2beed4c5fdc6deb93bf to your computer and use it in GitHub Desktop.
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
const array = [ ...Array(100).keys() ] | |
const msg = ['fizz', 'buzz', 'fizzbuzz'] | |
const startWithOne = x => x + 1 | |
const fizz = x => x % 3 ? '' : msg[0] | |
const buzz = x => x % 5 ? '' : msg[1] | |
const fizzbuzz = x => x % 15 ? '' : msg[2] | |
const verification = ( x ) => ( fizzbuzz ) || ( fizz ) || ( buzz ) || x | |
const result = array.map( startWithOne ).map( verification ).join( '\n' ) | |
console.log( result ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment