I replied to the specific question ( the difference from
\d$ ): about the challenge, if the ones in the last post are the only conditions, I’d suggest to use
\d*$ - the
* means 0 or more.
To avoid misunderstanding this is the meanings of the first two regExp posted:
let userCheck = /[a-z]|\d$/ig;
- Will match every string with a letter ([a-z] means it search for any character from a to z, the i flag means case unsensitive) OR (|) ends with a number
It doesn’t pass the challenge because it will match 007 (which should not).
I just tested it and it will satisfy the last condition: it should not match 9, but if you replace “JackOfAllTrades” with 9 or “9” and log the result is true as it should be - so this is a bug (probably related to the ‘g’ flag).
let userCheck = /[a-z]|d$/ig;
- Will match any string with any letter OR any string which ends with the letter d ( obviously redundant)
In short it will match any string that contains at least a letter, enough to pass the provided test cases ( even if it does not match the instructions )