Arrays often include items with missing numbers. A price may be undefined or null. Sum only the numbers and treat missing as 0.
const prices = [1, undefined, 3, null];
const total = prices.reduce((acc, p) => acc + (p ?? 0), 0);
Keep the function pure and return a number result.
Add up prices, skipping missing values.