Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08dd958

Browse files
authored
use const in rule "Use explanatory variables"
per preceding rule "ES6 constants when variable values do not change"
1 parent a22d1d9 commit 08dd958

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ for (var i = 0; i < MINUTES_IN_A_YEAR; i++) {
112112
### Use explanatory variables
113113
**Bad:**
114114
```javascript
115-
let cityStateRegex = /^(.+)[,\\s]+(.+?)\s*(\d{5})?$/;
115+
const cityStateRegex = /^(.+)[,\\s]+(.+?)\s*(\d{5})?$/;
116116
saveCityState(cityStateRegex.match(cityStateRegex)[1], cityStateRegex.match(cityStateRegex)[2]);
117117
```
118118

119119
**Good**:
120120
```javascript
121-
let cityStateRegex = /^(.+)[,\\s]+(.+?)\s*(\d{5})?$/;
122-
let match = cityStateRegex.match(cityStateRegex)
123-
let city = match[1];
124-
let state = match[2];
121+
const cityStateRegex = /^(.+)[,\\s]+(.+?)\s*(\d{5})?$/;
122+
const match = cityStateRegex.match(cityStateRegex)
123+
const city = match[1];
124+
const state = match[2];
125125
saveCityState(city, state);
126126
```
127127
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)