Tell us what’s happening:
Your code so far
function telephoneCheck(str) {
// Good luck!
// str.replace(/[#_]/g,'');
var str1;
var value;
str1=str.replace(/[-()\s]/g,'');
if(str.length>11)
{
for(var j=0;j<str.length;j++)
{
if(str[j]==")" || str[j]=="(")
{
return false;
}
}
}
if(str1.length==10)
{
for(var i=0;i<str1.length;i++)
{
if(str1[i]!==isNaN())
{
return true;
}
}
}
if(str1.length==11 && str1[0]==1)
{
return true;
}
return false;
}
telephoneCheck("(555-555-5555");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/validate-us-telephone-numbers