Validate US Telephone No. problem

Tell us what’s happening:
what exactly the \ operator does in regular expression? coz when m using (\(\d{3}\)|\d{3})then its passing all the tests…

Your code so far

 var regex=/^(1\s?)?((\d{3})|\d{3})(-|\s)?\d{3}(-|\s)?\d{4}$/;
  return regex.test(str);
}
telephoneCheck("555-555-5555");```

\ is an escape character. Some characters have special meaning within regex, such as parenthesis. So whenever you need your regex to match such characters literally - ignoring their special meaning - you have to put \ before them.

thank u sir…i got it now