File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,16 +102,17 @@ setTimeout(() => {
102102** Bad:**
103103``` javascript
104104const address = ' One Infinite Loop, Cupertino 95014' ;
105- const cityStateRegex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
105+ const city
106+ Regex = / ^ [^ ,\\ ] + [,\\ \s ] + (. +? )\s * (\d {5} )? $ / ;
106107saveCityState (address .match (cityStateRegex)[1 ], address .match (cityStateRegex)[2 ]);
107108```
108109
109110** Good** :
110111``` javascript
111112const 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 );
115116```
116117** [ ⬆ back to top] ( #table-of-contents ) **
117118
You can’t perform that action at this time.
0 commit comments