File tree
Expand file treeCollapse file tree1 file changed
+11
-8
lines changed Expand file treeCollapse file tree1 file changed
+11
-8
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -79,19 +79,22 @@ can help identify unnamed constants.
|
79 | 79 |
|
80 | 80 | **Bad:**
|
81 | 81 | ```javascript
|
82 |
| -// What the heck is 525600 for? |
83 |
| -for (let i = 0; i < 525600; i++) { |
84 |
| -runCronJob(); |
85 |
| -} |
| 82 | +// What the heck is 86400 for? |
| 83 | +setTimeout(() => { |
| 84 | +this.blastOff() |
| 85 | +}, 86400); |
| 86 | + |
86 | 87 | ```
|
87 | 88 |
|
88 | 89 | **Good**:
|
89 | 90 | ```javascript
|
90 | 91 | // Declare them as capitalized `const` globals.
|
91 |
| -const MINUTES_IN_A_YEAR = 525600; |
92 |
| -for (let i = 0; i < MINUTES_IN_A_YEAR; i++) { |
93 |
| -runCronJob(); |
94 |
| -} |
| 92 | +const SECONDS_IN_DAY = 86400; |
| 93 | + |
| 94 | +setTimeout(() => { |
| 95 | +this.blastOff() |
| 96 | +}, SECONDS_IN_A_DAY); |
| 97 | + |
95 | 98 | ```
|
96 | 99 | **[⬆ back to top](#table-of-contents)**
|
97 | 100 |
|
|
You can’t perform that action at this time.
0 commit comments