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