Mutations code does not return false

False values are not returning:

Your code so far

function mutation(arr) {
  let arr0 = arr[0].toLowerCase()
  let arr1 = arr[1].toLowerCase().split('');

  for (let i = 0; i < arr1.length; i++) {
    if (arr0.indexOf(arr1[i]) >= 0) {
      return true;
  return false;

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:

when does this return true?

1 Like

Hey @Mustycodes

It does not return because the function ends when it find the first letter in second array as per your if statement.

1 Like

Okay, i have seen the error, i changed the binary operator to <, then i changed the return values. But what if i was not to change the operator, what was i supposed to return. Please i need an explanation

you check first letter, first letter is included in the other word, it returns true
it would return true even if only one letter is included

you need to change the logic flow as it doesn’t check the whole word

1 Like

I have tried and still no difference. I guess i’ll just stick to the new solution

so you are returning true only if indexOf returns less than 0?

Remember to return false only if the character is not present in the arr[0].

1 Like