Could someone help me understand why I'm not passing this test? :(

But it’s returning true…

Your code so far

function telephoneCheck(str) {
let regex = /(^\d\d\d-\d\d\d-\d\d\d\d$)|(^\(\d\d\d\)\d\d\d-\d\d\d\d$)|(^\(\d\d\d\)\d\d\d-\d\d\d\d$)|(^\d\d\d \d\d\d \d\d\d\d$)|(^\d\d\d\d\d\d\d\d\d\d$)|(^1 \d\d\d \d\d\d \d\d\d\d$)|(^1 \(\d\d\d\) \d\d\d-\d\d\d\d$)|(^1 \d\d\d-\d\d\d-\d\d\d\d$)|(^1\(\d\d\d\)\d\d\d-\d\d\d\d$)/g;

return regex.test(str);


telephoneCheck("1 555-555-5555");
telephoneCheck("1 (555) 555-5555");
telephoneCheck("1 555 555 5555");
telephoneCheck("1 456 789 4444");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Telephone Number Validator

Link to the challenge:

maybe you are not passing the test because you didn’t study enough

1 Like

Hahaha looking at your other replies, I don’t know if you are trolling or not but whether that’s the case or not, you’re right! I actually passed the test after a bit of studying :stuck_out_tongue:

don’t use the g flag in a regex with the test method, it causes all its issues…
(check documentation on test method for more infos)

1 Like