If statement with indexOf method

I wrote a loop over each character of the test string that was meant to exit the loop if any index values with indexOf were -1. I thought that searching for -1 would work as well as searching for values greater than 0 as some solutions say.
With this example, all test values are present in the target meaning there is no index of -1. The loop should have contined to the end, said the target did not qualify to be false, and returned true.
As it is, with console.log( arr[0].indexOf(arr[1][i])) shows one index, then calls false. In the case that the if statement is commented out, the same console log shows the predicted list of indices with true. If you can, please help me understand the part that is inconsistent.

function mutation1(arr) {
  if (arr[0] === arr[1]) {
  return true;
  }
  for (let i = 0; i < arr[1].length; i++) {
    arr[0].indexOf(arr[1][i]);
    if (arr[0].indexOf(arr[1][i]== - 1))  {
      return false;
    }
  }
  return true;
}
mutation1(["quail and partridge", "partridge"]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.50.

Challenge: Mutations

Link to the challenge:

you may want to look carefully what you are searching in the string - it is not a character

this is what you are searching in the string

2 Likes

I capped indexOf before its result. Thank you for pointing out how simple the error is. That encouraged me to have another bit of patience.
if (arr[0].indexOf(arr[1][i]) == -1)