Tell us what’s happening:
When I use the global flag, it fails two of the tests (Your regex unRegex should match “sun” in “The sun is out today.” & Your regex unRegex should match “pun” in “Seven days without a pun makes one weak.”) and I can’t figure out why this is happening.
Your code so far
let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /.un/i; // 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/68.0.3440.106 Safari/537.36.
No bug. Just run the following in your browser’s console.
let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /.un/ig; // Change this line
console.log(unRegex.test("Let us go on a run.")); // displays true
console.log(unRegex.test("The sun is out today.")); // displays false
This phenomenon is best explained in the following Stack Overflow thread.