Please tell me what is wrong with my code . i didnt find any problem

Please tell me what is wrong with my code . i didnt find any problem
0

#1

Tell us what’s happening:

Your code so far

function mutation(arr) {
  
  var a=arr[0].toLowerCase().split("");
  var b=arr[1].toLowerCase();
  for(var i=0;i<b.length;i++){
    if(a.indexOf(b[i].split(""))!==-1){ return true;}
    return false;
  }
}

mutation(["hello", "hey"]);```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0```.

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

#2

Part of your problem is the use of split(’’) on the following line:

if(a.indexOf(b[i].split(""))!==-1){

If we look at the test case of:

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

a is an array which looks like [ ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ ]
b[0].split("") is an array of one element which looks like [ ‘h’ ]

When you write:

a.indexOf(b[i].split(""))

you are trying to find the index of an element in a (an array of string character) which is equal to [ ‘h’ ] which is an array of one string. An array is never going to be equal to a string, so this will return -1 and so the if statement evaluates to false, so you return false based on the return false statement following your if.

A secondary issue you will face (once you figure out you are making the wrong comparison above), is that your for loop will only iterate through one time, because you you execute a return statement (true or false). Once a return statement is executed, the for loop and the function are exited and nothing else happens.