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

Skip to content

Commit 19b1f36

Browse files
committed
feat(explanatory-variables): use destructuring
1 parent 2837f0f commit 19b1f36

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ saveCityState(cityStateRegex.match(cityStateRegex)[1], cityStateRegex.match(city
119119
**Good**:
120120
```javascript
121121
const cityStateRegex = /^(.+)[,\\s]+(.+?)\s*(\d{5})?$/;
122-
const match = cityStateRegex.match(cityStateRegex)
123-
const city = match[1];
124-
const state = match[2];
122+
const [, city, state] = cityStateRegex.match(cityStateRegex);
125123
saveCityState(city, state);
126124
```
127125
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)