ARTICLE AD BOX
Because arrow function didn't need 'return' for single line and arr.reduce function pass the first argument to next call. So we didn't need to return first argurment and also didn't need create the multiline arrow function and write return. but without that the code it give false result
The problem which I was trying to solve is

Correct solution:

Wrong Solution: But why this Solution not work

result:

5

Please post all code as text rather than images. Otherwise everyone trying to reproduce the problem has to type all the code in again, which is clearly a waste of time.
2026-04-12 07:39:51 +00:00
Commented 20 mins ago
You should also edit the text of the post to explain what you're trying to do. When the very first sentence starts with "Because", you're clearly missing context. Please read jonskeet.uk/links/stack-hints
2026-04-12 07:41:00 +00:00
Commented 19 mins ago
Ok thanks for advice
2026-04-12 07:41:12 +00:00
Commented 18 mins ago
Hint: how do you expect the value returned by the callback function to be used? What do you believe the value returned by (obj, value) => obj[value.id] = value is?
2026-04-12 07:46:45 +00:00
Commented 13 mins ago