Tell us what’s happening:
I tought the caret sign is for things we don’t want. Why is it a form of starting point. why is ther a | when the first half of it is already good?
Your code so far
let username = "JackOfAllTrades";
let userCheck = /change/; // Change this line
let result = userCheck.test(username);let username = "JackOfAllTrades";
let userCheck = /^[a-z][a-z]+\d*$|^[a-z]\d\d+$/i;
let result = userCheck.test(username);
console.log(result)
Code Explanation:
^ - start of input
[a-z] - first character is a letter
[a-z]+ - following characters are letters
\d*$ - input ends with 0 or more digits
| - or
^[a-z] - first character is a letter
\d\d+ - following characters are 2 or more digits
$ - end of input
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36
Challenge: Restrict Possible Usernames
Link to the challenge: