-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new-member-34: Calculate cost of basket #119
Comments
I tried to work this out but I can't see to access my newBasket array to log the object prices: var totalCost = 0; for(var i in itemPrices){ // Write a function, priceOfBasket, that returns the total cost of a basket of items. |
Hi Seyi - sorry for the slow reply! I haven't been receiving GitHub notifications for some reason. A few thoughts on your code:
I hope that helps. Good luck! |
Thank you, I've got it now. Do I submit the answer here? var totalCost = 0; var newBasket = ['banana', 'orange', 'apple', 'banana', 'orange', 'banana']; var priceofBasket = function(Basket) { return totalCost; priceOfBasket(newBasket); |
Great work Seyi! Almost there: I'd suggest one more tweak. Your function currently only takes Ideally your function should take two arguments ( When you're happy with your solution, you'll need to create a new file and push it to the appropriate directory in the repo. You can see the directions in the readme: https://github.com/codingforeveryone/js/blob/master/README.md Good luck! |
Calculate cost of basket
Write a function,
priceOfBasket
, that returns the total cost of a basket of items.Input will be:
{banana: 3, orange: 4, pear: 5, apple: 2}
['banana', 'orange', 'apple', 'banana', 'orange', 'banana']
Output should be:
19
The text was updated successfully, but these errors were encountered: