I need to add up a total for a shopping basket but I dont know how to do this using jade
Here is how I thought I could implement it but it doesnt work, other ways I have tried just keep throwing errors.
Does anyone know how I would do this?
each item in bagItems
- var total = total + item.realprice
p= total
This should be pretty easy to do using the reduce method on your array.
p= bagItems.reduce(function(total, item) { return total + item.realprice; }, 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With