Telephone Number Validator test code wont work

so ive tried to debug this code in FCC and in to try and understand what is happening. when running the code manually it works but for some reason with FCCs test code it does not work. pleas help me

function telephoneCheck(str) {
 let strArr = str.split(/[\D]/g);
 let lenght = 0;
for(let i = 0; i<strArr.length;i++){
   length += strArr[i].length;
  console.log("11 digits");
  return (11 == length);
  console.log("10 digits");
  return (10 == length);
return false;



Your browser information:

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

Link to the challenge:

1 Like

You spelled length wrong

What @JohnKalinauskas said, but also I think it’s not quite as simple as what you’re doing: so for example, the test for (555)5(55?)-5555") should return false. But if you remove all the non-digits, you get 5555555555, which is valid

1 Like