Difference between FCC editor and regular web browser?

Tell us what’s happening:

Hello Everyone.

Is there any difference how the code is interpreted in FCC editor and in my regular browser ? Because in this example /[a-z][a-z]/gi doesn’t match “Jo” whereas it does on my browser (Chrome).

What’s happening ?

PS : this code isn’t supposed to meet all the requirements of the exercise. It’s just a test.

Your code so far

let username = "Jo";
let userCheck = /[a-z][a-z]/gi; // 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/85.0.4183.121 Safari/537.36.

Challenge: Restrict Possible Usernames

Link to the challenge:

When we click run tests, it throws error that regex should match "Jo" but if you try printing the result using console.log(result) it shows true…
Maybe the tests are interrelated and checks for the regex pattern and not the value of result variable

1 Like

do not use the g flag with the test method

look at paragraph “Using test() on a regex with the “global” flag” in the docs:

1 Like