Tell us what’s happening:
mutation(["hello", "Hello"]);
Returns false, it’s the only test that fails.
I have tested this regex on regexr.com, using /[Hello]/gi as the regex and hello as the test and it matches no problem.
If I change my code to
return /[Hello]/gi.test(arr[0]);
Then it passes that test.
Why is it failing when I use the array reference in the regex?
Your code so far
function mutation(arr) {
return /[arr\[1\]]/gi.test(arr[0]);
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) 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/basic-algorithm-scripting/mutations