mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 00:28:25 -05:00
[guide] fix example 4.7 for arrays method callbacks
This commit is contained in:
committed by
Jordan Harband
parent
da0cf08831
commit
495a62aaa9
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user