Clarification on solutions

Tell us what’s happening:

My solution reads as follows: lookahead for any character appearing 5 or more times and lookahead again for a pattern of two non digits, one of which appearing zero or more times, with two consecutive digits followed.

whereas freecodecamp’s solution reads as follows: lookahead for a pattern that is of 6 character length and lookahead again for any character appearing zero or times, with 2 consecutive digits.

Is freecodecamp’s more general? And do I understand what is going on?

Your code so far

let sampleWord = "12345";
let pwRegex = /(?=\w{5,})(?=\D\D*\d{2})/; // or (?=\w{6})(?=\w*\d{2})
let result = pwRegex.test(sampleWord);
let result2 = sampleWord.match(pwRegex);

Challenge: Positive and Negative Lookahead

Link to the challenge:

It passes the test. I think FCC’s is more general. It says look for a pattern that is 6 characters long and has two digits in it.
So, “123456” passes.
Yours is saying: look for a pattern that is at least 5 characters long, and has a non-digit followed by maybe a non-digit and then two digits in it. The idea that there should be a non-digit in it, makes it less general. “123456” does not pass. You’ve got an improved version.


I think the guide was not uptdated when the challenge was changed last time, so the solution and hints may not work for current version of the challenge