#Can someone explain to me why this .reduce() function returns "undefined"?

10 messages · Page 1 of 1 (latest)

tulip harness
#

The arrow function version of my code works as expected and logs the correct value, however, the long notation gives me 'undefined' as a result.

fickle heath
#

looks ok... can you setup a scrim to show?

tulip harness
#

Yeah, give me a sec @fickle heath

fickle heath
#

Uncomment line 10... you need to return from the function

tulip harness
#

Do I need BOTH returns?

fickle heath
#

yep, the inner return is only to return for the reduce() callback... you need this for each item THEN you need to return the total that's calculated for the function

tulip harness
#

Thank you Bill :)

fickle heath
#

👍