Tell us what’s happening:
The below code works for half of the checks, then the code below it that is commented out fulfills the other half of the checks. What did I overlook?
also what is the correct syntax to say:
match an open bracket with a closed bracket 3 digits later otherwise create a capture group of the space character. What am I doing incorrectly?
Your code so far
function telephoneCheck(str) {
var regex1= /(?:1\s)?(\d{3})|(\(\1\))[-\s]?\1[-\s]?\d{4}/
return regex1.test(str);
}
telephoneCheck("555-555-5555");
// /(?:1\s)?\d{3}(\(\d{3}\))[-\s]?\d{3}[-\s]?\d{4}/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator