Created
February 15, 2021 23:26
-
-
Save YannickLeRoux/7c2c8421133d79a5816923adad83e03f to your computer and use it in GitHub Desktop.
Example Ramda - compose map and reduce
This file contains hidden or 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 * as R from 'ramda' | |
const foods = [{item: 'bread', calories: 500},{item: 'cheese', calories: 300},{item: 'ham', calories: 200}] | |
const getTotalCalories = R.compose(R.reduce(R.add,0),R.map(R.prop('calories'))) | |
console.log(getTotalCalories(foods)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment