© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Michael Geary
const sum = arr.reduce((result, item) => { result = result + item; return result; });
Since result is local to the callback, you can simplify this to:
result
const sum = arr.reduce((result, item) => { return result + item; });
Subha Chanda
Technical Writer | Developer
Thank you for the suggestion. 😊 I was thinking to use this code, const sum = arr.reduce((result, item) => result + item); But because it's not much beginner-friendly, so I chose to go with the one above.