Why my code can't pass the test?

**Why my code can’t get false in this test case:
telephoneCheck("(6054756961)");
**

  **Your code so far**

function telephoneCheck(str) {

let checkNum = str.replace(/[^\d]/g, "");
let hasPermittedCharsOnly = str.match(/[\s|\-]/g);
let twoOr0 = str.match(/[/(/)]/g);

 if(checkNum.length === 10 || (checkNum.length === 11 && str.charAt(0) == 1)){
  
   if( hasPermittedCharsOnly === null){
    return true;
  }else if(hasPermittedCharsOnly.length + checkNum.length == str.length){
    return true;
  }else if(twoOr0.length === 2 && (/\d$/).test(str) && (str.charAt(0) === "(" && str.charAt(4) === ")") || ((str.charAt(1) === "(" && str.charAt(5) === ")")) || (str.charAt(2) === "(" && str.charAt(6) === ")")){
    return true;
  }else{
    return false;
  }
}else{
   return false;
}
}
 
telephoneCheck("(6054756961)");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36.

Challenge: Telephone Number Validator

Link to the challenge:

Thank you, RandellDawson,
With this case in my browser, I get false, but in the code tester of the task, I didn’t get false. Why?

let twoOr0 = str.match(/[/(/)]/g);
if((/\(\d{3}\b\)/).test(str) && twoOr0.length === 2){
      return true;
    }else{
      return false;
    }

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