An accumulator can combine values while a loop visits an array. It starts before the loop and changes once for each item.
const prices = [4, 6];
let total = 0;
for (const price of prices) {
total += price;
}
console.log(total);Read the supplied loop and predict the final value of total. Replace the empty prediction without changing how the actual total is calculated.
Track the running total after each pass, not just the current item.