Compare character in array

I’m having brain fart on how to comparing characters through each element in an array.

Can someone please give me some hints on how to proceed.

My code so far:

function mutation(arr) {

  let word1 = arr[0].toLowerCase();
  let word2 = arr[1].toLowerCase();

  for (let i = 0; i < arr.length; i++) {
    
    if (word1[i].includes(word2[i])){
      return true
    }
  }
  return false;
}

mutation(["hello", "hey"]);

Can you explain why you want to loop over the array of words?

Oh… shi** :slight_smile:

That is a very good question indeed! I should loop over word1 and then compare it to word2… :man_facepalming:

1 Like