ovirex
1
Tell us what’s happening:
That’s my answer and the program gives it to me as correct, but when I see the hint’s answer it’s very different from mine.
Your code so far
let username = "JackOfAllTrades";
let userCheck = /.\D./i; // Change this line
let result = userCheck.test(username);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames
ovirex
2
This also correct, I would like to understand why.
let username = "JackOfAllTrades2442";
let userCheck = /[a-z]\d*/ig; // Change this line
let result = userCheck.test(username);
console.log(result);
6in
3
There are 3 conditions and both two regex it’s not exact:
- The only numbers in the username have to be at the end. There can be zero or more of them at the end.
Important: $
means at the end of string
- Username letters can be lowercase and uppercase.
- Usernames have to be at least two characters long. A two-letter username can only use alphabet letter characters.
This is my solution /^[a-zA-Z]{2,}\d*$/
1 Like