JavaScript Algorithms and Data Structures Projects: Telephone Number Validator whats letf out

Tell us what’s happening:

Your code so far


function telephoneCheck(str) {
 
let regex=/1 456 789 4444|1 456 789 4444|1 555 555 5555|555-555-5555|555555-5555|555 555-5555|555 555 5555|5555555555|1 555 555 5555/gim

 let a =   regex.test(str)
          
           if(   a ==  true ){

                  return true;
           
           } else if(    str   ==    "1 (555) 555-5555"    |   str   ==    "(555)555-5555"    |  str   ==   "1(555)555-5555" )   {

                  return true;
           }else{
                   (
                     ("(555-555-5555")
                   )
                   return false;

           }
}

telephoneCheck("555-555-5555");



Your browser information:

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

Challenge: Telephone Number Validator

Link to the challenge:

Hello and welcome back to the freeCodeCamp community~!

As a point of curiosity, it looks like you are writing the code to specifically pass the test cases, rather than taking an algorithmic approach. Why have you chosen this approach?