US Telephone Number Validator

I’ve been trying to validate US numbers for days now and would really appreciate your help . My code is bellow and I still have 3 more types of numbers to validate.

telephoneCheck(“1 555)555-5555”)
those 3 must return false

my code so far…

function telephoneCheck(str) {
var phoneRegex = /^([1]\s?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

if (phoneRegex.test(str)) {
  return true;
} else {
  return false;

  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36

Challenge: Telephone Number Validator

Link to the challenge:

you are missing to check that brackets must be in matching pairs

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.