Review: Mutations Challenge

Hello Friends
I’ve just completed my Mutations Challenge and want you all to please review it and let me know if it needs some improvements.

Many thanks in advance. Here’s the code:

function mutation(arr) {
  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  var myArr = arr[1].split('');
  
  for (var i = 0; i < myArr.length; i++) {
    if (arr[0].indexOf(myArr[i]) < 0) {
      return false;
    }
  }
  return true;
}

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

Happy Coding! :smile:

1 Like

Thank you for your reply. Adding lowercase versions are the part of challenge, that’s why I’ve added them. Here is the challenge:

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.
For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".
Remember to use Read-Search-Ask if you get stuck. Write your own code.

For better reading you can visit the link: https://www.freecodecamp.com/challenges/mutations

May be i was not clear, I just need opinion to do it with best practice. If i skip the lowercase then it will not show me h == H. That’s why looking for help. What will be the best practice if i skip the lowercase, then how can i evaluate the lower & upper case?

Hope you understand my problem here.