-
-
Save suzdalnitski/c21ad38d28339bb87eee76bad650686c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { filter, first, get } from 'lodash/fp'; | |
const filterByType = type => | |
filter( x => x.type === type ); | |
const fruits = [ | |
{ type: 'apple', price: 1.99 }, | |
{ type: 'orange', price: 2.99 }, | |
{ type: 'grape', price: 44.95 } | |
]; | |
const getFruitPrice = type => fruits => | |
fruits | |
|> filterByType(type) | |
|> first | |
|> get('price'); | |
const getApplePrice = getFruitPrice('apple'); | |
console.log('apple price', getApplePrice(fruits)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment