MediumArray Methods💻 Output Question

reduce accumulates to a single value

💡

Hint

reduce is the most powerful array method — it can produce any output type.

What does this output?

const items = ['hello', 'world', 'foo'];
const total = items.reduce((acc, w) => acc + w.length, 0);
console.log(total);

Correct Output

13

Why this output?

Explanation: 5+5+3=13. reduce folds the array into one value.

Key Insight: reduce is the most powerful array method — it can produce any output type.

More Array Methods Output Questions

Easymap transforms each elementMediumfilter then map chainMediumfind returns first match; filter returns allMediumreduce to build a frequency object

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz