Regex Solution Not Valid… Why? From: “Regular Expressions: Restrict Possible Usernames”

Hi, I’m stuck with this exercise because this solution is not valid if it meets the conditions. I am looking forward to your response

let userCheck = /^[a-z]+(\D$|\d{2,}$)/gi;

let username = "JackOfAllTrades";
let userCheck = /^[a-z]+(\D$|\d{2,}$)/gi
// Change this line
let result = userCheck.test(username);
   **Your browser information:**

Challenge: Restrict Possible Usernames

Link to the challenge:

Well, it is not passing because it doesn’t work.

I do notice your global flag, g. There is an issue with using that with test. It will work for single tests in the console but the multiple tests in the test suite will fail. If I remove that, all but one of the tests is failing.

See if you can figure out why that last test is failing. If you get stuck, check back.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.