Challenge Error

Okay so I think it is something wrong with the challenge because it says that:
mutation(["ate", "date"]) should return false .

But I think it should be true because the letters in the first string are also found in the second string I don’t understand why?
Thank you for the help!

My code so far:

function mutation(arr) {

  const str1 = arr[0].toLowerCase().split('');

  const str2 = arr[1].toLowerCase().split('');

  if (str1.length > str2.length || str1.length == str2.length) {

    for (let i = 0; i < str2.length; i++) {

      if (str1.indexOf(str2[i]) == -1) {

        return false;

      }

    }

    return true;

  } else if(str1.length < str2.length) {

      for (let i = 0; i < str1.length; i++) {

        if (str2.indexOf(str1[i]) == -1) {

          return false;

        }

      }

      return true;

    }

}

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

  **Your browser information:**

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

Challenge: Mutations

Link to the challenge:

I think you have it backwards

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

That worked, thank you very much!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.