Mutations - Not getting into false condition

Mutations - Not getting into false condition
0

#1

Tell us what’s happening:
My if statement is not getting satisfied. Have I made mistakes anywhere?. Thanks in advance.
Your code so far
This is my code so far:


function mutation(arr) {
  var string1charArray = arr[0].toLowerCase().split('');
  var string2charArray = arr[1].toLowerCase().split('');

  for (var i=0; i<string2charArray.length; i++){
    if (string1charArray.indexOf(string2charArray[i]) === -1) {
      return false;
    }
    else {
      return true;
    }

  }
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations


#2

You’re checking only the first character ^^
Does it not match? Return false.
Does it match? Return true.
End. :stuck_out_tongue:

Below a tip^^

Remove the else condition and move elsewhere your return true statement :wink: