Last active
January 28, 2018 06:57
-
-
Save daniellealexis/586719b9b30b5e7256f3ab7875bb58f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 coffeeShoppe = {}; | |
| coffeeShoppe.coffee = 5.25; | |
| coffeeShoppe.latte = 4.25; | |
| coffeeShoppe.cheesecake = 4.00; | |
| coffeeShoppe.getProductPrice = function(productName){ | |
| return this[productName]; | |
| } | |
| coffeeShoppe.calculateTotalPrice = function(productList) { | |
| let total = 0; | |
| const productCount = productList.length; | |
| for (var i = 0; i < productCount; i++) { | |
| var price= this.getProductPrice(productList[i]); | |
| if (typeof price == 'number') { | |
| total += price; | |
| } | |
| } | |
| return total;; | |
| } | |
| coffeeShoppe.calculateTotalPrice(['bagel', 'coffee','latte']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment