The problem with this challenge is that there are a couple ways of doing it that pass all the given tests, but that donât adhere to the username rules set out in the explanation. Iâve bolded numbers one and three because this is where the inconsistency arises.
Here are some simple rules that users have to follow when creating their username.
1) The only numbers in the username have to be at the end. There can be zero or more of them at the end.
- Username letters can be lowercase and uppercase.
3) Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.
Change the regex userCheck
to fit the constraints listed above.
The challenge lays out these constraints but then doesnât actually test for them, allowing you to pass it without fulfilling these requirements. My first passing attempt (I donât remember what I used now) did exactly that. It passed all the tests, so I was allowed to move on, but it didnât fulfill constraint one or three.
On another note, the solution given in the hints section: /{2,}\d*$/i;
, while passing all the tests, doesnât allow for a username such as âD48â, for example, because it requires the first two characters to be letters. But the constraints only specify that the characters must be letters only when the username is only 2 characters long. A 3 character username can technically only contain one letter and the rest numbers.
As for your solution @shashgo: /{1}\d+$ | {2,}\d*$/
. While it does pass the tests and allow you to move on, it likewise doesnât adhere to the third constraint. A username such as âH8â is returned as true when it should be false.
I think I have found a solution that passes all the test and still follows all the constraints set out in the challenge that arenât tested for: /{1}\d{2,}$|{2,}\d*$/i;
.
Sorry for the long-windedness, but I was confused by the given constraints in this test and the possible solutions, so hopefully the next person to search the forum about this issue can find what theyâre looking for in this post.