Codington
0 of 10 problems solved • 0%
Use in a course

Exercise prompt

Trace an Array Total

An accumulator can combine values while a loop visits an array. It starts before the loop and changes once for each item.

Example

const prices = [4, 6]; let total = 0; for (const price of prices) { total += price; } console.log(total);

Your task

Read the supplied loop and predict the final value of total. Replace the empty prediction without changing how the actual total is calculated.

Hint

Track the running total after each pass, not just the current item.