diff --git a/index.html b/index.html index ba64788..7512537 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@
diff --git a/javascripts/json_store.js b/javascripts/json_store.js index e07a756..72279a1 100644 --- a/javascripts/json_store.js +++ b/javascripts/json_store.js @@ -49,8 +49,15 @@ $.each(this.session('cart') || {}, function(id, quantity) { sum += quantity; }); + + // function to decide whether use "items" or "item" + var plural = function(num) { + return ( num > 1 ) ? 'items' : 'item'; + }; + $('.cart-info') .find('.cart-items').text(sum).end() + .find('.cart-plural').text( plural(sum) ).end() .animate({paddingTop: '30px'}) .animate({paddingTop: '10px'}); });