File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1309,7 +1309,6 @@ Other Style Guides
1309
1309
for (let num of numbers) {
1310
1310
sum += num;
1311
1311
}
1312
-
1313
1312
sum === 15;
1314
1313
1315
1314
// good
@@ -1320,6 +1319,19 @@ Other Style Guides
1320
1319
// best (use the functional force)
1321
1320
const sum = numbers.reduce((total, num) => total + num, 0);
1322
1321
sum === 15;
1322
+
1323
+ // bad
1324
+ const modified = [];
1325
+ for (let i = 0; i < numbers.length; i++) {
1326
+ modified.push(numbers[i] + 1);
1327
+ }
1328
+
1329
+ // good
1330
+ const modified = [];
1331
+ numbers.forEach(num => modified.push(num + 1));
1332
+
1333
+ // best (keeping it functional)
1334
+ const modified = numbers.map(num => num + 1);
1323
1335
```
1324
1336
1325
1337
<a name="generators--nope"></a><a name="11.2"></a>
You can’t perform that action at this time.
0 commit comments