loading...

re: Mastering Hard Parts of JavaScript: Callbacks I VIEW POST

FULL DISCUSSION
 

Current reduce implementation is wrong - it will handle first item twice if you will not set initialValue.

 

Thanks for picking that up! Should be fixed now 😀

 

if (Object.keys(arguments).length > 2) {

I think you can just use arguments.length. Cheers!

better yet, typeof initialValue !== 'undefined' so you avoid touching arguments at all

initialValue can be undefined

yes...but accum = initialValue loses its purpose if it is.

Code of Conduct Report abuse