Skip to content

Instantly share code, notes, and snippets.

@viniazvd
Created June 19, 2017 21:49
Show Gist options
  • Save viniazvd/4d7843a360eee2beed4c5fdc6deb93bf to your computer and use it in GitHub Desktop.
Save viniazvd/4d7843a360eee2beed4c5fdc6deb93bf to your computer and use it in GitHub Desktop.
fizzbuzz
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