Skip to content

Instantly share code, notes, and snippets.

@ducdigital
Created April 17, 2015 08:03
Show Gist options
  • Save ducdigital/19a2d5b4073a51fd541d to your computer and use it in GitHub Desktop.
Save ducdigital/19a2d5b4073a51fd541d to your computer and use it in GitHub Desktop.
Maping price to a priceIndex
var index, pppClient, currencyPrice;
pppClient = _.find(menu.fixedPriceMapClient, function (price) {
return price.from <= 6 && price.to >= 6;
});
currencyPrice = menuPrices[menu.currency];
if (!!pppClient) {
index = _.findIndex(currencyPrice, function (v,index) {
if (typeof currencyPrice[index+1] === 'undefined') {
return false;
}
return this <= (currencyPrice[index] + (currencyPrice[index+1] - currencyPrice[index])/2);
}, pppClient.ppp);
}
if (menu.freePPP) {
index = -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment