Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
JavaScript
/
Array methods
Why should a sum over a possibly empty array usually pass 0 to reduce?
from Array methods
Node 24
beginner
1 min
Why should a sum over a possibly empty array usually pass 0 to reduce?
It defines the empty result and prevents reduce from throwing on an empty array.
It makes reduce mutate the array in place.
It makes the callback run twice for every value.
Check
Ask AI about this kata
Report an error
previous kata
What does this program print?
Predict the output
next kata
Review a generated order report
Review AI code
A new version is available
Reload