Tell us what’s happening:
I successfully match all items except Z97.
To start, check for a match of 2 letters at the beginning. Then, look for a match of 0 or more numbers at the end of the regex.
Not sure how to allow numbers as a second character so long as the password is over 2 characters.
Your code so far
let username = "Ofd1";
let userCheck = /^[A-Za-z][A-Za-z]+[0-9]*$/; // Change this line
let result = userCheck.test(username);
console.log(userCheck.test(username));
console.log(username.match(userCheck));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
.
Challenge: Restrict Possible Usernames
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames