Skip to content

Instantly share code, notes, and snippets.

@iboss-ptk
Created July 4, 2019 04:23
Show Gist options
  • Select an option

  • Save iboss-ptk/ce5a8ae61cc13eab97bed8893fd86895 to your computer and use it in GitHub Desktop.

Select an option

Save iboss-ptk/ce5a8ae61cc13eab97bed8893fd86895 to your computer and use it in GitHub Desktop.
const id = exp => exp
const promo = exp => exp * 2
const trueCash = exp => exp * 10
const makeTotalExp = upgraders => monsters => monsters
.reduce((totalExp, monster) => {
const upgradedExp = upgraders
.reduce((upgradedExp, upgrade) => upgrade(upgradedExp), monster.exp)
return totalExp + upgradedExp
}, 0)
const totalExp = makeTotalExp([id])
const totalExpPromo = makeTotalExp([promo])
const totalExpTrueCash = makeTotalExp([trueCash])
const totalExpTrueCashPromo = makeTotalExp([trueCash, promo])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment