Skip to content

Instantly share code, notes, and snippets.

@aviladev
Created August 31, 2018 17:20
Show Gist options
  • Save aviladev/baeb65251904ebf9b48a37ff9985a7e4 to your computer and use it in GitHub Desktop.
Save aviladev/baeb65251904ebf9b48a37ff9985a7e4 to your computer and use it in GitHub Desktop.
'use strict'
const characters = [
{ name: 'ironman', env: 'marvel' },
{ name: 'black_widow', env: 'marvel' },
{ name: 'wonder_woman', env: 'dc_comics' },
]
characters
.filter( propEq('env', 'marvel') )
.map( merge({ alsoSeenIn: ['Avengers'] }) )
characters
.reduce((acc, character) =>
propEq('env', 'marvel', character)
? acc.concat( merge({ alsoSeenIn: ['Avengers'] }, character) )
: acc
, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment