#HELP NEEDED PLEASE

3 messages · Page 1 of 1 (latest)

tame spire
#

I am trying to add up the total accumulative amount. Message me if you are capable of helping me.

golden crater
#

Good morning, Lyle!

It looks like quantity isn't being declared in the calculateTotal() function or the .reduce() method. Also in the return statement for calculateTotal() change it to be:

return price * quantity;

The code says return accumulate = price * quantity but assigning a value to accumulate isn't necessary since the reduce() method automatically does that with the return statement.

I hope this helps 🙂

tame spire
#

Thank you @golden crater. I changed the code instead using cart.forEach(item =>{ total += eval(item.price)})
totalElement.textContent = $${total}