Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the example code for array.reduce can't get the expected result #45

Open
qiaoxingxing opened this issue Oct 25, 2018 · 0 comments
Open

Comments

@qiaoxingxing
Copy link

qiaoxingxing commented Oct 25, 2018

the example code for array.reduce can't get the expected result.
in order to get the expected result 0, the second line should change + to - .

[55, 44, 33, 22, 11].reduce(function(p, c, i, arr){
//return p + c/(arr. length-i);
return p - c/(arr. length-i);
}, 55); // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant