Stuck on Mutation challenge

Stuck on Mutation challenge
0

#1

I have been stuck on this challenge for over a day. I am unable to get all “green checks” and not sure what to do. Please help:

'function mutation(arr) {
for (i = 0; i < arr.length; i++){
res= arr.sort(arr[i]);

if(res.indexOf(i) !== -1);
}
return false;

}
mutation([“hello”, “hey”]);’


#2

Hey, have a look at your code. What does the if statement do? Also you only return false, no matter what.


#3

This if statement is to compare if the characters in the second argument exists in the first argument. If not it should return false.

I originally had the if statement as follows:

if(res.indexOf(i) !== if(res.indexOf(0));

but it did not work either even though it returned false


#4

But the if statement doesn’t do anything. if(res.indexOf(i) !== -1); It just checks it and goes on. An if statement should be as follows:

if(<check>){ 
  // do something 
}

So that would be:

if(res.indexOf(i) !== -1){
  return false;
}else{
  return true; 
}