Why this code doesn't functionnate?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
function telephoneCheck(str) {

let regex=/(^1?)(-?)(\s?)(\(?)([0-9][0-9][0-9])(\))(-?)(\s?)([0-9][0-9][0-9])(-?)(\s?)([0-9][0-9][0-9][0-9]$)/
return regex.test(str);


  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0

Challenge: Telephone Number Validator

Link to the challenge:

it requires the presence of the )

And as a side note, this regex could be greatly optimized. You don’t need that many capturing groups, also, you may use quantifiers and escape sequences for digits.

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