Describe your problem and how to reproduce it:
To solve the challenge for Restrict Possible Usernames you need to understand "quantity specifiers" (e.g. {2,}
).
Quantity specifiers aren't taught until a few lessons later in the Curriculum (Specify upper and lower number of matches).
Suggest moving the Restrict Possible Usernames challenge a few places down the Curriculum.
Note: This is a duplicate of issue 25676, but is still ongoing.
Add a Link to the page with the problem:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames
and:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/specify-upper-and-lower-number-of-matches
Tell us about your browser and operating system:
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
@samcottle This challenge can definitely be solved without using lower or upper specifiers. I am closing this issue due to the fact the challenge does not need to be moved.
@RandellDawson Both the solution provided on freeCodeCamp for Restrict Possible Usernames, and the freeCodeCamp YouTube video Learn Regular Expressions uses them.
For example, here's the solution for Restrict Possible Usernames:
That may be the case, but it can still be solved without using {2,}
. Just think about another way to match 2 or more letters.
Hi all,
I know this issue was closed but I have just hit the same wall. Unsure of how to solve the challenge, I clicked 'Get a hint' which lead me to a solution containing code that had yet to be taught in the curriculum. From the perspective of someone learning this material, it's a bit of a kick in the teeth that the 'solution' provided is something I couldn't possibly know just by going through the curriculum.
As quantity specifiers come later, I would suggest moving this challenge or changing the solution to an alternative method containing only expressions used so far (even if it isn't the most elegant). Maybe: /^[a-z][a-z]+\d*$/i;
?
PS This is my first contribution here (at least I hope it is a contribution) so apologies if I'm doing it wrong!
I agree with the suggestion to move the challenge. The suggested solution makes use of both quantity specifiers and character groups before they are taught.
Getting around the quantity specifier is easy enough but the result still includes character groups.
/^[a-z](\d\d\d*|[a-z]+\d*)$/i
@RandellDawson can you please suggest a solution that doesn't use either of these so that the suggested solution may be updated?
P.S. I also thought of /^[a-z][a-z]+\d*$/i
initially but it doesn't match the test case with Z97
, which is a valid username.
@sultanofcardio The solution you see in the md
file is used only by devs to test if their changes prevent the challenge from passing a solution.
This topic was discussed on the forum here: https://forum.freecodecamp.org/t/restrict-possible-usernames-solution-requires-knowledge-not-introduced/395660/7
The guide post has the visible solution, and it has been updated with a perfectly suitable solution:
let username = "JackOfAllTrades";
let userCheck = /^[a-z][a-z]+\d*$|^[a-z]\d\d+$/i;
let result = userCheck.test(username);
Thank you @Sky020.
I tried something like this but I neglected to duplicate the $
and ^
symbols.
Most helpful comment
Hi all,
I know this issue was closed but I have just hit the same wall. Unsure of how to solve the challenge, I clicked 'Get a hint' which lead me to a solution containing code that had yet to be taught in the curriculum. From the perspective of someone learning this material, it's a bit of a kick in the teeth that the 'solution' provided is something I couldn't possibly know just by going through the curriculum.
As quantity specifiers come later, I would suggest moving this challenge or changing the solution to an alternative method containing only expressions used so far (even if it isn't the most elegant). Maybe:
/^[a-z][a-z]+\d*$/i;
?PS This is my first contribution here (at least I hope it is a contribution) so apologies if I'm doing it wrong!