Skip to content

Instantly share code, notes, and snippets.

@clemherreman
Created October 25, 2011 15:00
Show Gist options
  • Select an option

  • Save clemherreman/1313041 to your computer and use it in GitHub Desktop.

Select an option

Save clemherreman/1313041 to your computer and use it in GitHub Desktop.
Anonymous functions returning anonymous functions that return what you need.
var qty = parseInt(element.find('.qty').val()) || 0;
var possiblePrices = tierPrices[productId];
var tierPrice = jQuery.grep(possiblePrices , (function(qty) {
var qty = qty || 1;
return function(possiblePrice) {
return (possiblePrice.qty_min <= qty)
&& ((possiblePrice.qty_max > qty) || (possiblePrice.qty_max === 'infinity'));
}
})(qty))[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment