Regex exercise question

Tell us what’s happening:

I don’t understand why this solution works for the challenge. Instead of using (?=\w{5,}) I was using (?=\w{6,}) because in the instructions it says the password string should only match if it is least six characters long.

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36.

Challenge: Positive and Negative Lookahead

Link to the challenge:

JS is 0 based. it means it starts counting from 0.
When you are specifying 6 in your Regex, you’re basically asking it for at least 7.

and you are right, but it passes the same, there are no tests for a string of length 5 so I never solved my doubt for this challenge.

that’s not true, when counting stuff it counts from 1 (like in an array, you have items at index 0,1 and 2 - the length of the array is 3)

I’m aware of that.
The only explanation that made sense to me was that. if it’s not true, I’ll look into it further and find out the reason.

both pass because there is no test for a string of length five, only of length six of above.
The challenge instructions could be interpreted both as “at least 5 characters”, or “at least 6 characters” by people.
There is not a test that specify which is the correct one.

you can open a bug for this if you want

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

I see.
Thanks for making the time to look it up!