Why am I not able to match sun

Tell us what’s happening:

I am able to solve all the other objectives but not “sun”

Your code so far

let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /.un/gi; // Change this line
let result = unRegex.test(exampleStr);

Your browser information:

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

Challenge: Match Anything with Wildcard Period

Link to the challenge:

Thank you, for bringing this to my attention. I have been looking for this issue. This issue has been mentioned on the GitHub repo.

A quick solution is to remove the g flag at the end of your regex.

But Why is it happening ? only with the “sun”
I don’t think I understand this!

You can read about the issue here: https://github.com/freeCodeCamp/freeCodeCamp/issues/37890

1 Like

Thank you so much, So global isn’t necessary, So we reject it?

In this case, global is not necessary, but your solution is not incorrect with it; the tests just need to be adjusted slightly, as this was an unexpected bug.

1 Like