File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -102,16 +102,17 @@ setTimeout(() => {
102
102
** Bad:**
103
103
``` javascript
104
104
const address = ' One Infinite Loop, Cupertino 95014' ;
105
- const cityStateRegex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
105
+ const city
106
+ Regex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
106
107
saveCityState (address .match (cityStateRegex)[1 ], address .match (cityStateRegex)[2 ]);
107
108
```
108
109
109
110
** Good** :
110
111
``` javascript
111
112
const address = ' One Infinite Loop, Cupertino 95014' ;
112
- const cityStateRegex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
113
- const [, city , state ] = address .match (cityStateRegex );
114
- saveCityState (city, state );
113
+ const cityZipCodeRegex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
114
+ const [, city , zipCode ] = address .match (cityZipCodeRegex );
115
+ saveCityState (city, zipCode );
115
116
```
116
117
** [ ⬆ back to top] ( #table-of-contents ) **
117
118
You can’t perform that action at this time.
0 commit comments