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
13091309 for (let num of numbers) {
13101310 sum += num;
13111311 }
1312-
13131312 sum === 15;
13141313
13151314 // good
@@ -1320,6 +1319,19 @@ Other Style Guides
13201319 // best (use the functional force)
13211320 const sum = numbers.reduce((total, num) => total + num, 0);
13221321 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);
13231335 ```
13241336
13251337 <a name="generators--nope"></a><a name="11.2"></a>
You can’t perform that action at this time.
0 commit comments