Skip to content

Instantly share code, notes, and snippets.

@syzer
Last active November 16, 2015 16:14
Show Gist options
  • Save syzer/907e2489dbb978212c73 to your computer and use it in GitHub Desktop.
Save syzer/907e2489dbb978212c73 to your computer and use it in GitHub Desktop.
map without ifs , and loops
// here condR === undefined
const falsy = (condL, condR) => condL !== condR;
const map = (fn, [first, ...rest]) =>
(falsy(first) && []) && [fn(first), ...map(fn, rest)];
console.log(':)', map((x) => (x + x), [1, 2, 3]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment