We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a48ec89 commit dd05edfCopy full SHA for dd05edf
JavaScript-Algorithms-and-Data-Structures-Projects/Telephone-Number-Validator.js
@@ -0,0 +1,10 @@
1
+function telephoneCheck(str) {
2
+ const re = /^(1\s?)?\d{3}([-\s]?)\d{3}\2\d{4}$/;
3
+ const re2 = /^(1\s?)?\(\d{3}\)\s?\d{3}[-\s]\d{4}$/;
4
+ if (re.test(str)) {
5
+ return true;
6
+ }
7
+ else {return re2.test(str) ? true : false}
8
+}
9
+
10
+telephoneCheck("555-555-5555");
0 commit comments