Skip to content

Instantly share code, notes, and snippets.

@pragmaticobjects
Created September 10, 2011 22:08
Show Gist options
  • Select an option

  • Save pragmaticobjects/1208863 to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticobjects/1208863 to your computer and use it in GitHub Desktop.
var tax= 0.08;
var fee = 10;
var sinTax = 0.02;
(function f(item, price) {
var h = {
'gas': function() {
var total = price + price*tax + fee;
alert(total);
},
'wine': function() {
var total = price + price*tax + price*sinTax;
alert(total);
}
};
typeof h[item] == 'undefined' ?
(function() {
var total = price + price*tax;
alert(total);
})() : h[item]();
})('milk', 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment