Mutations freeCodeCamp Help needed

Tell us what’s happening:

Your code so far

function mutation(arr) {
  var str = arr[1];
  var main = arr[0];
  var arr1 = [];
  arr1 = arr[0].split("");
  //return arr1;
  var arr2 = [];
  arr2 = arr[1].split("");
  var count1;
  var count2;
  for(i= 0 ; i<arr[1].length;i++){
    if((arr1[i] !== arr2[i])){
      count1++;
    }
  }
  
  for(i= arr[1].length; i >0;i--){
    if((arr1[i] !== arr2[i])){
      count2++;
    }
  }
  if(count1 > 0 || count2 > 0){
    return true;
  }else {
    return false;
  }
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0.

Link to the challenge:
https://www.freecodecamp.org/challenges/mutations

What improvements do i have to make ??

You should use the String.prototype.indexOf() function, it helps finding a char in a string.
And as said @camperextraordinaire, use comments to explain what the code is doing :slight_smile:

comparing every word of the two words

i have used substr() method and it also doesn’t help me i worked out for all except three test cases. P.S . I am trying to approach in a different way.:sweat_smile:

Okay, I see the problem here,

you only check if char in arr1 are equal to char in arr2 one by one (first char equals first char, second char equals second char, …)
You need to check if first char of arr2 is equal to any char of arr1 (using indexOf will help for this)