The tests for this challenge seem to miss one edge case. The code I have passes all the tests given.
I think for example a username of “J007” should match given the spec. It is more than 2 characters long so only the first character needs to be a letter.
However, I can’t figure out how to make that pass, but also have the restriction that a two character username should only have letters (i.e. “J7” should not be a match).
I could just submit and carry on, but I’d love to know how to fix this corner case too
Your code so far
let username = "JackOfAllTrades";
let userCheck = /^[a-z]{2,}\d*$/i; // Change this line
let result = userCheck.test(username);
console.log(userCheck.test("J007")==true); \\should pass but fails
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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