medium10 pts · first answer countsjavascriptarrays
reduce on an empty array
A cart total is calculated like this. What happens when the cart is empty?
const prices = [] const total = prices.reduce((sum, p) => sum + p)
A cart total is calculated like this. What happens when the cart is empty?
const prices = [] const total = prices.reduce((sum, p) => sum + p)