Restrict Possible Usernames Broken?

Tell us what’s happening:

Pretty confident my regEx should work. From my repl I’ve tried the following code.
let regex = /^[a-zA-Z]{2,}[\d]*$/;

let term = ‘JACK’;

let ans = regex.test(term);

console.log(ans);
And it matches fine. Yet from the lesson it isn’t passing.

Your code so far


let username = "JackOfAllTrades";
let userCheck = /^[a-z A-Z]{2,}[\d]*$/ig; // Change this line
let result = userCheck.test(username);

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 11151.113.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.127 Safari/537.36.

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

The problem is your global tag:

Your choice of adding a case-insensitive tag is also redundant, since you included both A-Z and a-z in your pattern.

You weren’t intended to add any tags, which is why the word “change” appears inside the regular expresions.

1 Like

thanks I added the [A-Z] while trying to figure out why it wasn’t working. several of the previous assignments required a tag. But your suggestions got me unstuck so thanks.