Tell us what’s happening:
I don’t know if this is wrong, but it’s passing the tests. As per my understanding, /[A-Za-z][A-Za-z]+\d*$/
makes it compulsory to have 2 letters at the start. However, the challenge doesn’t ask for the 1st 2 characters to be letters - it is only in the case of a 2 character string that both need to be letters.
So J90 should be a valid case, but for this, my regex will not match. Or perhaps the task description needs to be updated to specifically mention 2 or more letters at the start.?
Your code so far
let username = "JackOfAllTrades";
let userCheck = /[A-Za-z][A-Za-z]+\d*$/; // Change this line
let result = userCheck.test(username);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames/