Restrict Possible Usernames, it should not match Z97

let username = "JackOfAllTrades";
let userCheck = /^[a-z]+[a-z]+\d*$/i; // Change this line
let result = userCheck.test(username);

console.log(result)

it should not match “Z97”, everything else that should match or not match works

what is it missing from userCheck ?

Fairly simple solution without using regex:

if (username !== "Z97") {
return "ok";
} else {
return "Z97 is not allowed";
};

yeah why to complicate :sweat_smile:

In the assignment expected results it says that Z97 should match regex. So you’d need to create an expression that also allows for
letter number number
combinations.
It doesn’t say so in the conditions as it explains the assignment, but it’s in the expected results.

It’s a valid name according to the rules presented in the challenge

Usernames can only use alpha-numeric characters.
The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
Username letters can be lowercase and uppercase.
Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.

The instructions say all usernames are 2 or more characters. If they are three+ characters, then they must have at least one letter at the start, and they can be ended by any number of numbers.

Understanding the 4 rules is a big part of this challenge.

1 Like

please post the challenge link, if possible

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