Skip to content

Instantly share code, notes, and snippets.

@bradurani
Last active September 17, 2015 04:57
Show Gist options
  • Save bradurani/6a0c57364e074b47f3e5 to your computer and use it in GitHub Desktop.
Save bradurani/6a0c57364e074b47f3e5 to your computer and use it in GitHub Desktop.
Function Injection After
function tacoRank(taco){
...
}
function findBestTacos(rankingFunction, restaurants) {
return restaurants.reduce((acc, next) => { return acc.concat(next.tacos) }, [])
.sort((a, b) => { rankingFunction(a) - rankingFunction(b) })
.slice(0, 10);
}
findBestTacos(tacoRank, restaurants);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment