Mutations - Console shows correct answers but tests fail

My code returns the correct answer in the console, but when I run the tests about half of the tests fail. I have double checked each individual test, and they all produce the correct answer in my console.
Can someone please tell me why?
Thanks.

Your code so far


function mutation(arr) {
let letters1 = arr[0].toLowerCase().split("");
let letters2 = arr[1].toLowerCase().split("");
let finalRes = "true";
for (let i=0; i<letters2.length; i++) {
  let patt = new RegExp(letters2[i]);
  let res = patt.test(letters1);
  if (res == false) {
    finalRes = false;
    //break;
  }
}
return finalRes;
};

//tests:
//mutation(["hello", "hey"]);
//mutation(["hello", "Hello"]);
//mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
//mutation(["Mary", "Army"]);
//mutation(["Mary", "Aarmy"]);
//mutation(["Alien", "line"])
//mutation(["floor", "for"]);
//mutation(["Noel", "Ole"]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12739.111.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36.

Challenge: Mutations

Link to the challenge:

are the tests that fail those that should return true?

true and "true" are not the same thing

2 Likes

Ah, good catch! Thank you for your help.