Basic Algorithm Scripting: Mutations using RegExp

Tell us what’s happening:
I am trying to use regular expressions to solve this. I run into an error on the return statement indicating that arr[0].test is not a function.
Can anyone help me understand why this is not working?


Your code so far

function mutation(arr) {
  let testStr = `[${arr[1]}]`;
  let testRE = new RegExp(testStr, 'ig');
  return arr[0].test(testRE);

mutation(["hello", "hey"]);

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.

Link to the challenge:

According to, the syntax for the test() method is regexObj.test(str).

Since arr[0] isn’t a regexObj but a string, using .test() throws an error.