[guide] fix example 4.7 for arrays method callbacks

This commit is contained in:
Matthias Pries
2019-02-13 13:52:39 +01:00
committed by Jordan Harband
parent da0cf08831
commit 495a62aaa9

View File

@@ -423,13 +423,11 @@ Other Style Guides
// bad - no returned value means `acc` becomes undefined after the first iteration
[[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => {
const flatten = acc.concat(item);
acc[index] = flatten;
});
// good
[[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => {
const flatten = acc.concat(item);
acc[index] = flatten;
return flatten;
});