When I test the code using console.log I get true, but when I try to run the test I get false. What is happening? Am I doing something wrong?
updated my regex to /^[1]?[\s]?((([2-9]{1}[0-9]{2}))|[2-9]{1}[0-9]{2})(-|\s)?((([2-9]{1}[0-9]{2}))|[2-9]{1}[0-9]{2})(-|\s)?[0-9]{4}$/g, since the last wasn’t really right. Still, having the same problems, testing every single number on console gives me the expected result, but when I run the test every result ends up being false.
Strange…
Taking away every console.log() and doing nothing else seems to have done the trick… not sure what happened, but at least I got the challenge complete.
It’s because you’re using the global flag:
1 Like