JavaScript Map, Reduce and Filter Functions Introduction Arrays are important Data Structures in programming. All the methods which we are going to discuss in this article will iterate over an array and return a new array based on the result function...

Markdown supported · ⌘↵ to post
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.
Michael Geary
const sum = arr.reduce((result, item) => { result = result + item; return result; });Since
resultis local to the callback, you can simplify this to:const sum = arr.reduce((result, item) => { return result + item; });