Not sure why my code isn’t working for
mutation([“hello”, “hey”]) should return false.
Currently, it’s returning true, while all of the rest of the scenarios are working properly. Here is my code:
function mutation(arr) {
var leftSplit = arr[0].toLowerCase();
var rightSplit = arr[1].toLowerCase();
for (var i = 0; i < arr[1].length; i++) {
var temp = leftSplit.indexOf(rightSplit[i]);
if (temp === -1) {
return false;
}
return true;
}
}
mutation(["hello", "hey"]);
if I do a console.log if temp in the loop, I do see it gets -1, so shouldn’t that be returning false?