Mutation exercise. code works for oth. strings but not this one. wheres my mistake. hints have indexof() instead of RegExp constructor

function mutation(arr) {
 let newArr=arr[1].split('')
let testThis;

 for(let i=0; i < newArr.length; i++){
    testThis = new RegExp(`${newArr[i]}`, 'i')
   if(testThis.test(arr[0])) {
       return true;
   }
   return false;
 }
}

mutation(["hello", "hey"]);
console.log(mutation(["hello", "hey"]))

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

The fact that your solution passes all of the other tests is almost complete coincidence.

The reason I say that is your for loop only every makes one iteration before returning true or false which means you are only ever checking whether the first character of the second string tests true for the regex generated. You will need to rethink your logic.