Phone number validation

Tell us what’s happening:
I cant seem to figure out why this is not working, can anyone lend a fresh pair of eyes?

Your code so far

function telephoneCheck(str) {
var cleanStr = str.replace(/\W/g,'')
const tenDigits = /[0-9]{10}/;
const elevenDigits = /\d{11}/;
const withOne = /^1/;
const numsOnly = /^\d+$/;
const correctParen = /((\d{3}))/;

// Set up your Booleans here
let hasTenDigits = tenDigits.test(cleanStr);
let hasElevenDigits = elevenDigits.test(cleanStr);
let startsWithOne = withOne.test(cleanStr)
let hasPermittedCharsOnly = numsOnly.test(cleanStr);
let hasCorrectParentheses = correctParen.test(cleanStr);
// Use the Booleans to return true or false, without needing to string together one complex regular expression
if (!hasTenDigits && !hasElevenDigits) {
return false;
} else if (!hasPermittedCharsOnly || !hasCorrectParentheses) {
return false;
} else if (hasElevenDigits && !startsWithOne) {
return false;
} else {
return true;

console.log(telephoneCheck("1 555-555-5555"));

Your browser information:

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

Challenge: Telephone Number Validator

Link to the challenge:

Take a look at troublesome tests, what cleanStr such cases produce, and whether later separate regex checks are what they should be for the cases. There’s a lot of edge cases that can slip through if regexes aren’t precise enough.