Telephone Number Validator (About US phone number format)

Tell us what’s happening:

Your code so far


function telephoneCheck(str) {
  // Good luck!
  return true;
}

telephoneCheck("555-555-5555");

Link to the challenge:

I am doing this challenge right now, the thing I want to ask has nothing to do with logic or coding.
I am not from the US, could someone explain the US phone number format a little bit?

There are a few example that are given from the quest:

555-555-5555
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555

So, my understanding is that there are a few requirements:

  1. 10 digit with numbers only
  2. if the user added 1 in front of the 10 digit it counts too.

So, the thing I need to get rid of from the user inputs are non-number letter. What about 2 555 555 5555, is this a valid number??

also parentheses, em dashesand and whitespaces must be positioned only as they are in examples.

1 Like

hmmm I see. I think I need to make some changes with my Regex.
Thanks for the tip.

1 Like

can I understand it in this way,

555-555-5555
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555

only these formats are correct , as long as it is not listed above it is invalid number.