I need some help with my regExp to validated phone number

Tell us what’s happening:
I’m trying to create just one regexp to pass all test but I need a little help on how to make the regular expression validate the two numbers between parentheses and when it starts with 1 and then space and then parenthesis

Your code so far


function telephoneCheck(str) {
// Good luck!
let patter = /^1?(\d{3})[(\d{3})]?[-/s]*(\d{3})[-/s]*(\d{4})$/g
return patter.test(str)
}

console.clear()
console.log(telephoneCheck("555-555-5555"));
console.log(telephoneCheck('555 555 5555'))
console.log(telephoneCheck("(555)555-5555"));
console.log(telephoneCheck("1 (555) 555-5555"));
console.log(telephoneCheck("5555555555"));
console.log(telephoneCheck("555)-555-5555"))
console.log(telephoneCheck("1 555 555 5555"));
//console.log(telephoneCheck("8oo-six427676;laskdjf"))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.136 YaBrowser/20.2.2.177 Yowser/2.5 Safari/537.36.

Challenge: Telephone Number Validator

Link to the challenge:

Well, you don’t have any logic to allow a space after the 1 in your pattern.

There are also some online tools that can help (regexr and regex101). Here is the MDN docs as well.

let patter = /^1?\s?(\d{3}|\([0-9]{3}\))[-\s]\d{3}[-\s]\d{4}|\d{10}|^1?\([0-9]{3}\)\d{3}[-\s]\d{4}/g
  return patter.test(str)

I almost done with this pattern but I don’t understand why in this cases don’t return false

telephoneCheck("(6054756961)")
telephoneCheck(“27576227382”)

If you see it broken down like this, does that help?