Hello,
I cannot figure out why the following code doesn’t test [“hello”, “hey”] to false as I’d expect.
function mutation(arr) {
var arr1 = arr[0].toLowerCase();
var arr2 = arr[1].toLowerCase();
for (var ii = 0; ii < arr2.length; ii ++) {
for (var i = 0; i < arr1.length; i++) {
if (arr2[ii] === arr1[i]) {
return true;
}
}
return false;
}
}
mutation(["hello", "hey"]);
The logic of the code I wrote was:
- creating two arrays from the original one
- changing all letters to lowercase
- looping through each array with a nested for loop and checking if entries are the same with “===”
Please note that this code passes 11 tests out of 12.
Why can’t it pass the first one?