const {curry, filter, contains, prop} = R const collection = [{ type: 1, eyes: 'blue'},{ type: 2, eyes: 'brown'}, { type: 3, eyes: 'green'}, { type: 4, eyes: 'blue'}] const array = [1, 2, 4] const filterBy = curry((propName, selectedValues, collection) => filter(e => contains(prop(propName, e), selectedValues), collection)) const newCollection = filterBy('type', array, collection) console.log(newCollection)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter