Tell us what’s happening:
So I’m working on Regular Expressions: Restrict Possible Usernames and I know what I have (using /w
, instead of matching letters only) doesn’t satisfy the challenge, I’m just trying some things trying to get a hang of RegExs by playing around with it (RegExs seem great and I’m excited about this chapter, lots of fun), but I can’t figure out what is going on here. on let result = userCheck.test(username);
The right side of the operation returns false, but the left side returns true. What am I missing?
Your code so far
//let username = "JackOfAllTrades";
let username = "RegexGuru"; // Just trying thing out
let userCheck = /^\w{2,}\d*$/gi; // my line
// let userCheck = /^\w+\w+\d*$/gi; something else I tried that doesn't seem to be good
let result = userCheck.test(username);
console.log(result); // returns true but
console.log(userCheck.test(username)); // returns flase
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames/