This code should have passed

let username = "JackOfAllTrades";
let userCheck = /^[a-z][a-z]*([a-z]+|[0-9][0-9]+)[0-9]*$/gi; // Change this line
let result = userCheck.test(username);
console.log(result)
This code literally passes every condition of the lesson and also the ones enlisted at the bottom of the challenge. But on hitting the ctrl+ enter , it doesn't work.


**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames

I think you are supposed to call the match function on the string, not the test on regex.

1 Like

You need to remove the global flag /g.

You can read a bit more about how the flag works with the test() method. The challenge is executing multiple tests, not just one.

1 Like