Created
November 2, 2014 01:48
-
-
Save JacobHsu/efd9186e3fee55afd940 to your computer and use it in GitHub Desktop.
#JS Building a Cash Register
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cashRegister = { | |
total:0, | |
add: function(itemCost){ | |
this.total += itemCost; | |
} | |
}; | |
//call the add method for our items | |
var items = [0.98, 1.23, 4.99, 0.45]; | |
for(i=0;i<items.length;i++){ | |
cashRegister.add(items[i]); | |
} | |
//Show the total bill | |
console.log('Your bill is '+cashRegister.total); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment