Closed Bug 1563354 Opened 7 years ago Closed 7 years ago

Array.prototype.reduce()

Categories

(developer.mozilla.org Graveyard :: Collaboration, defect)

All
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: brizid, Unassigned)

Details

(Keywords: in-triage, Whiteboard: [specification][type:bug])

Attachments

(1 file)

What did you do?

1.  Expected output with error.

What happened?

Exemple:

const array1 = [10.1, 10.2, 10.3, 10.4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;

console.log(array1.reduce(reducer));
// expected output: 41

console.log(array1.reduce(reducer, 5));
// expected output: 46

What should have happened?

Present the correct result.
// Result
//> 41
//> 45.99999999999999

Is there anything else we should know?

Attached image bug reduce.png
Flags: needinfo?(cmills)

I've tested the array values you are using in Chrome and Firefox, both in the interactive MDN example, and in the devtools, and they all give the same unexpected result. So this looks more like a quirk of how JS behaves than a problem with MDN or Firefox.

Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(cmills)
Resolution: --- → INVALID
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: