Skip to content

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

@qiaoxingxing

Description

@qiaoxingxing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions