Tell us what’s happening:
using g makes “JACK” return false while removing it makes it return true although g
is the abbreviation for global and its function is to return the multiple occurrences of the same word in the same line. briefly; g
is responsible only for returning a string array instead of a string. right?
Your code so far
let username = "JackOfAllTrades";
let userCheck = /\w+\d*$/; // Change this line
let result = userCheck.test(username);
console.log(userCheck.test("JACK"))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
.
Challenge: Restrict Possible Usernames
Link to the challenge: