File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -1521,24 +1521,28 @@ Other Style Guides
1521
1521
1522
1522
let array = [1 , 2 , 3 ];
1523
1523
let num = 1 ;
1524
- let increment = num ++ ;
1525
- let decrement = -- num;
1524
+ num ++ ;
1525
+ -- num;
1526
1526
1527
+ let sum = 0 ;
1528
+ let truthyCount = 0 ;
1527
1529
for (let i = 0 ; i < array .length ; i++ ){
1528
1530
let value = array[i];
1529
- ++ value;
1531
+ sum += value;
1532
+ if (value) {
1533
+ truthyCount++ ;
1534
+ }
1530
1535
}
1531
1536
1532
1537
// good
1533
1538
1534
1539
let array = [1 , 2 , 3 ];
1535
1540
let num = 1 ;
1536
- let increment = num += 1 ;
1537
- let decrement = num -= 1 ;
1541
+ num += 1 ;
1542
+ num -= 1 ;
1538
1543
1539
- array .forEach ((value ) => {
1540
- value += 1 ;
1541
- });
1544
+ const sum = array .reduce ((a , b ) => a + b, 0 );
1545
+ const truthyCount = array .filter (Boolean ).length ;
1542
1546
` ` `
1543
1547
1544
1548
**[⬆ back to top](#table-of-contents)**
You can’t perform that action at this time.
0 commit comments