I am trying to return the total cost of party supplies for an event, however the return I am getting is isNaN. Is the problem how I am accessing ‘supplies[j]’?
Regards
const supplyList = {
plates: 2,
cups: 1,
forks: 1,
partyHats: 4 };
function orderSupplies(supplies, guests) {
let totalCost = 0;
for (let i = 0; i < guests; i++) {
for (let j = 0; j < Object.keys(supplies).length; j++) {
totalCost += supplies[j];
}
}
return totalCost;
}
Hey! I have a question so I can understand a little better! Could you provide some more context around the supplyList and the number of supplies that you need per guest and if this changes at all? also could you let me know how much those individual supplies cost so we can consider this too? Many thanks, Tom
The cost of each item is the value to each items key (2 plates, 1 cup etc…).
I am simply trying to add the total cost of the SupplyList multiplied by the number of guests attending.