Restrict Possible Usernames | This Answer Passes All But One Test

Restrict Possible Usernames | This Answer Passes All But One Test
0

#1

Tell us what’s happening:
My code passes the test in the console, but not on the FCC test window. It’s frustrating because “RegexGuru” returns “RegexGuru” yet I’m being told it’s not. Can someone tell me what I’m missing.?

Your code so far


let username = "RegexGuru";
let userCheck = /^[A-Z][A-Z]\w*/gi; // Change this line
let result = username.match(userCheck);
console.log(result);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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


#2


Here’s what I am seeing.


#3

You are only supposed to change the line with the comment of “Change this line”. For some reason, you also changed the third line from:

let result = userCheck.test(username);

to this:

let result = userCheck.match(username);

Try to changing match back to test and create an applicable regular expression to solve this challenge.

Hint: Do you need the “g” flag?


#4

Thank you! This worked.