Skip to content

Commit 3767dd1

Browse files
added 56
1 parent ac1cc15 commit 3767dd1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,3 +2056,38 @@ function maxTotal(nums){
20562056
20572057
---
20582058
**[⬆ 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)**

0 commit comments

Comments
 (0)