Validate US Telephone Numbers Challenge - Help needed

Validate US Telephone Numbers Challenge - Help needed
0

#1

I passed all the tests except for one.

And it doesn’t seem to add up… Basically, I divided the regex into a couple of parts.
The first part is the one that checks for a possible number 1 (country code) in front of other numbers.
^1?
Then the captured group #1 checks for different possibilities :
( ?\d{3} ?| ?(\d{3}) ?| ?\d{3}-)
It checks for 3 digits in a row possibly surrounded by white spaces,or 3 digits in a row surrounded by brackets and possible white spaces, or 3 digits in a row preceded by a possible white space and followed by a dash.
Then regex checks for captured group #2 :
(\d{3}[- ]?)
It checks for 3 digits in a row,possibly followed by a dash or a white space.
Finally it checks the third captured group #3:
(\d{4})
It checks for 4 digits in a row.
It is all wrapped in a word boundary.
Not sure if I am missing something here.There is the ^ sign that I set in front of the part that checks for possible number 1 (the country code) and I have doubts that the mistake in the code is associated with that,but as I said, I am really not sure if in absence of country code this ^ sign somehow applies to the first captured group or something…
Is there a specific solution for the problem that I am having,or is there another way I should have approached the problem.
The reason I have doubts about this part is because
telephoneCheck("(555)555-5555") returns false, but
telephoneCheck(“1(555)555-5555”) returns true
Could someone help me? I have been stuck for hours




function telephoneCheck(str) {
  var regex = /\b^1?( ?\d{3} ?| ?\(\d{3}\) ?| ?\d{3}-)(\d{3}[- ]?)(\d{4})\b/g;
  var matcher = str.match(regex);
  if (matcher) return true;
  return false;
}

telephoneCheck("(555)555-5555"); // This returns false for some reason