A common pattern is accumulating values:
let numbers = [10, 20, 30, 40]
let sum = 0
for (let num of numbers) {
sum += num
}
console.log(sum) // 100
Start with an initial value ( for sum, for product, empty string for concatenation). Add to it each iteration. The variable holds the final result after the loop.