Hello,
I have written a solution for the challenge, as i thought it might work, obviously it didn’t. I have looked at the hint section and saw the correct answer eventually.
What I would like to ask is if my code could be made to work and give the same output. And if not, why ?
Your code so far
let username = "JackOfAllTrades";
// Change this line
if ( username.length > 2) {
var userCheck = /\d*$/;
} else if ( username.length = 2 ){
var userCheck = /^[a-z]/;
}
let result = userCheck.test(username);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 OPR/58.0.3135.132
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames