In the telephone number validator problem. i have passed all the test except these two where:
function telephoneCheck(str) {
var regex= /^[1]*[ |\(]*\d{3}[-]*[\)]*[ ]*\d{3}[ |-]*\d{4}$/g
return regex.test(str)
}
console.log(telephoneCheck("1 555)555-5555"));
telephoneCheck("1 555)555-5555") should return false.
telephoneCheck("(555-555-5555") should return false.
In both cases , i cannot make logic of in all three section if one section has opening bracket it should also have closing bracket
If lookaheads should be used they how to manage the \d{3} which comes in between.
Please Help
link:https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator