If one of the test usernames was “1JackOfAllTrades”, your solution wouldn’t have passed. So like chuckadams said, the tests were made in such a way that there are loopholes. This was probably unintended by the authors of the challenge.
Right now, your regular expression evaluates to:
- any letter or number (\w)
- any non-number (\D)
When you use this regular expression in .test(), it checks the provided string and returns true or false depending on whether the string contains that particular configuration. In other words, it checks if the string contains any letter or number, and is followed by any non-number.
Taking a look at the correct solution:
let userCheck = /^[a-z]{2,}\d*$/i;
Notice it uses the caret (^) and question mark (?) characters. In a previous challenge, these were introduced as Beginning String and Ending String characters.
The solution under Get a Hint breaks down the regular expression:
/\d*$/
This evaluates to any number (\d), occurring zero or more times (*), occurring only at the end of the string ($).
Next:
/\d*$/i;
This evaluates to the regular expression, but with the flag that accepts uppercase or lowercase (i).
Finally:
/^[a-z]{2,}\d*$/i;
The first half of the regular expression evaluates to the following occurring at the beginning of the string (^), that being any letter ([a-z]), that must appear at minimum two times ({2,}).
I just checked and all of these characters are covered in the Regular Expressions section, so you should be able to reference them again and come to a full understanding of the correct solution.