Skip to content

Commit 2380c0d

Browse files
thepeoplesbourgeoisljharb
authored andcommitted
[guide] Improve severity of warning comment
1 parent 3ad1ad1 commit 2380c0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,10 @@ Other Style Guides
381381

382382
```javascript
383383
// bad
384-
const bar = [...foo].map(bar);
384+
const baz = [...foo].map(bar);
385385
386386
// good
387-
const bar = Array.from(foo, bar);
387+
const baz = Array.from(foo, bar);
388388
```
389389

390390
<a name="arrays--callback-return"></a><a name="4.5"></a>
@@ -400,18 +400,18 @@ Other Style Guides
400400
// good
401401
[1, 2, 3].map(x => x + 1);
402402

403-
// bad
403+
// bad - no returned value means `memo` becomes undefined after the first iteration
404404
const flat = {};
405405
[[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => {
406406
const flatten = memo.concat(item);
407-
flat[index] = flatten;
407+
memo[index] = flatten;
408408
});
409409

410410
// good
411411
const flat = {};
412412
[[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => {
413413
const flatten = memo.concat(item);
414-
flat[index] = flatten;
414+
memo[index] = flatten;
415415
return flatten;
416416
});
417417

0 commit comments

Comments
 (0)