Are any of the JS tutorials correct!?!?

Tell us what’s happening:
In almost every single lesson I find errors in the lessons. It can be the description is wrong or the task that needs to be performed is poorly written. Then when you click the “get hint” even the solutions are wrong most of the time. Take this one for example. My solution is below and passes the validation checks however I decided to see how it compared to the official solution. (Read the challenge tasks)

Your code so far


let sampleWord = "astronaut";
let pwRegex = /^[a-z](?=\w{5,})(?=\D*\d\d+)/i; // Change this line
let result = pwRegex.test(sampleWord);

Mine passes fine but below is the offical solution and why it is wrong.

Official Solution

^(?=\w{6})(?=\D+\d{2})

Let’s translate this. Right off the bat, the very first character is wrong, it says \w which matches letters and numbers yet the instructions clearly say it must start with letters only. So this should be [a-zA-Z]. And then it says it must be greater than 5 chars but the solution has {6} which matches EXACTLY 6 when it should be {6,} for 6 or greater…

I’m a noob at JS and Regex. Now if I can spot these mistakes straight away then how can I be confident in the skill level for who writes the solutions??

Challenge: Positive and Negative Lookahead

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

ok so can you please break each part down as I still don’t understand. I get the second group, but the first group says ^ as in start with then followed by \w which means digits too!??

ok I see what you are saying. When you explain it like that it makes sense. But the lesson doesn’t make that clear. From previous lessons it implies that the first bracket must match first (as in first 6 chars are alphanumeric) then AFTER those chars it evaluates the second bracket stating that 1 more or non digits followed by 2 digits (in other words it’s sequential). If this is not how the syntax works then it should be clearly explained like you just did.

So the solution is correct but as I said in my opening statement it is either the solution or descriptions or lessons that are wrong. IMO the lesson doesn’t explain this syntax enough; the lesson clearly explains look ahead (what it’s about) but not about that two sets of brackets means AND. Or am I understanding this wrong too?

There is no AND in that statement. I think because you understand how it should work, you read the word AND in there but it actually isn’t there lol, By stating “check two or more patterns” it still isn’t clear that both patterns must match the string from start to finish, it could be as I interpreted it (like previous lessons) where the pattern matching was sequential.

Regardless, you’ve cleared it up for me, I might add to the issue you linked to. thanks,