---
title: "Comment by Michael Geary on \"A Brief Introduction to JavaScript Map, Filter and Reduce Methods\" | Hashnode"
description: "const sum = arr.reduce((result, item) =&gt; { result = result + item; return result; }); Since result is local to the callback, you can simplify this to: const"
url: "https://hashnode.com/posts/a-brief-introduction-to-javascript-map-filter-and-reduce-methods/5f0c090c3fe8405bdb8d8194/comment/5f1693ade37a46613e6fe777"
---

[Discussion](https://hashnode.com/posts/a-brief-introduction-to-javascript-map-filter-and-reduce-methods/5f0c090c3fe8405bdb8d8194)

Comment [A Brief Introduction to JavaScript Map, Filter and Reduce Methods](https://hashnode.com/posts/a-brief-introduction-to-javascript-map-filter-and-reduce-methods/5f0c090c3fe8405bdb8d8194)

[Michael Geary](https://hashnode.com/@Geary)

[Jul 21, 2020](https://hashnode.com/posts/a-brief-introduction-to-javascript-map-filter-and-reduce-methods/5f0c090c3fe8405bdb8d8194/comment/5f1693ade37a46613e6fe777)

```
const sum = arr.reduce((result, item) => {
  result = result + item;
  return result;
});
```

Since `result` is local to the callback, you can simplify this to:

```
const sum = arr.reduce((result, item) => {
  return result + item;
});
```

[Subha Chanda](https://hashnode.com/@nemo)

[Jul 21, 2020](https://hashnode.com/posts/a-brief-introduction-to-javascript-map-filter-and-reduce-methods/5f0c090c3fe8405bdb8d8194/comment/5f1693ade37a46613e6fe777#reply-5f16f59ce37a46613e6feaa1)

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.
