Skip to content

Instantly share code, notes, and snippets.

@bradurani
Last active September 17, 2015 05:08
Show Gist options
  • Save bradurani/02f523c9688ad5b62fce to your computer and use it in GitHub Desktop.
Save bradurani/02f523c9688ad5b62fce to your computer and use it in GitHub Desktop.
Function Injection Brad
function bradRank(){
... //rate beef tongue very highly
}
function findBestTacos(rankingFunction, restaurants) {
return restaurants.reduce((acc, next) => { return acc.concat(next.tacos) }, [])
.sort((a, b) => { rankingFunction(a) - rankingFunction(b) })
.slice(0, 10);
}
let bradTopTen = findBestTacos.bind(null, bradRank); //returns a function
highestRankedForRestaurantsOpenSunday(bradTopTen, restaurants);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment