Tell us what’s happening:
telephoneCheck(“1 555)555-5555”)
How to check if open ‘(’ bracket exists we need to have ‘)’ too?
Your code so far
function telephoneCheck(str) {
var rex=/^1{0,1}\s?\(?\d{3}\)?(-|\s)?\d{3}(-|\s)?\d{4}/g;
// Good luck!
if(str.match(rex)){
return true;
}
return false;
}
telephoneCheck("555-555-5555");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
.
Link to the challenge: