File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -2056,3 +2056,38 @@ function maxTotal(nums){
2056
2056
2057
2057
---
2058
2058
**[⬆ Back to Top](#header)**
2059
+
2060
+
2061
+
2062
+ ##### 56. Write a regular expression that matches a string if and only if it is a valid zip code.
2063
+
2064
+ ###### Must only contain numbers (no non-digits allowed).
2065
+ ###### Must not contain any spaces.
2066
+ ###### Must not be greater than 5 digits in length.
2067
+
2068
+
2069
+
2070
+ ` ` ` js
2071
+ function isValidZip (zip ){
2072
+ // Write Your solution Here
2073
+ };
2074
+
2075
+
2076
+ console .log (isValidZip (" 393939" )); // false
2077
+ console .log (isValidZip (" 59001" )); // true
2078
+ console .log (isValidZip (" 853a7" )); // false
2079
+ ` ` `
2080
+
2081
+ <details><summary style="cursor:pointer">Solution</summary>
2082
+
2083
+ ` ` ` js
2084
+ function isValidZip (zip ) {
2085
+ const REXEX = / ^ \d {5} $ / ;
2086
+ return REXEX .test (zip);
2087
+ }
2088
+ ` ` `
2089
+
2090
+ </details>
2091
+
2092
+ ---
2093
+ **[⬆ Back to Top](#header)**
You can’t perform that action at this time.
0 commit comments