Positive and Negative Lookahead possible bug?

Tell us what’s happening:

So, from what I can see in the instructions, my code should not pass because of the fact it only looks for one number and not two. Is this the case? I do know now that I need to add {2,} after the /d to make it look for 2 digits.

Your code so far


let sampleWord = "astronaut";
let pwRegex = /(?=\w{5})(?=\D*\d)/; // Change this line
let result = pwRegex.test(sampleWord);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead

I would guess you are correct but can you double check by putting your regex through www.regextester.com and just test against a string with one number to see if it will match?

So, using www.regextester.com and my example here shows that the above code will match if just one number and not two. The instructions for the lesson indicate that the expression must match two numbers, so the lesson appears to be broken.

If there’s not an issue already on the freecodecamp curriculum GitHub repo you should open one

And if you feel so inclined you could fix it yourself with a pull request