What happens here?
const arr = [];
const total = arr.reduce((sum, n) => sum + n);
console.log(total);
- 0
- undefined
- NaN
- TypeError
0
voters
What happens here?
const arr = [];
const total = arr.reduce((sum, n) => sum + n);
console.log(total);
JS Quiz answer: Option 4 (D).
Correct choice: TypeError
Why:
reduce on an empty array without an initial value throws TypeError.
Go deeper:
First-answer leaderboard
Ngl I always forget this one and end up with a runtime error. it’s like the boss fight you keep thinking you’ve mastered.
:: Copyright KIRUPA 2026 //--
``` ```