I almost got this working, I just need to find out why it is return true when I input mutation([“hello”, “hey”]);
My code so far
function mutation(arr) {
var arr1 = arr[0];
var arr2 = arr[1];
var res = arr1.toLowerCase();
var res2 = arr2.toLowerCase();
var sliced = res.split("");
var sliced2 = res2.split("");
for (var int = 0; int < arr2.length; int++)
{
if (sliced.indexOf(sliced2[int]) >= 0)
{
return true;
}
else
{
return false;
}
}
}
mutation(["hello", "hey"]);