Restrict Possible Usernames errors

my code doesnt pass the following:
Your regex should match JACK
Your regex should match RegexGuru
can somebody help?

Your code so far


let username = "JackOfAllTrades";
let userCheck = /[A-Za-z][0-9$]/g; // Change this line
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/72.0.3626.119 Safari/537.36.

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

let userCheck = /^[a-z]{2,}\d*$/i;

Look here

  1. The only numbers in the username have to be at the end. \d$ There can be zero or more of them at the end. *
/\d*$/;
  1. Username letters can be lowercase and uppercase. i
/\d*$/i;
  1. Usernames have to be at least two characters long. {2,} A two-letter username can only use alphabet letter characters. ^[a-z]
/^[a-z]{2,}\d*$/i;
1 Like

Your regex will match a word that ends with a letter and a number, you need to add quantity specifiers to both. Also you will need also to add the match for the beginning of the string

Quantity specifier because you need at least 2 letters, and then you can 0 or more numbers at the end of the word

1 Like