Skip to content

Instantly share code, notes, and snippets.

@CharlesAMoss
Last active February 29, 2016 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlesAMoss/63f832367ae19bd7f3c8 to your computer and use it in GitHub Desktop.
Save CharlesAMoss/63f832367ae19bd7f3c8 to your computer and use it in GitHub Desktop.
fizzbuzz es6 plus .map
const myArray = [1,2,3,4,5,6,7,8,9,10,15];
let zed = z => (z % 3 === 0 && z % 5 === 0) ? "fizzbuzz" :
(z % 3 === 0 ) ? "fizz" :
(z % 5 === 0 ) ? "buzz" :
z;
console.log(myArray.map(zed)); // [1,2,"fizz",4,"buzz","fizz",7,8,"fizz","buzz","fizzbuzz"]
// transpiled with babeljs ver 5.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment