Basic Algorithm Scripting : Mutations : have to convert to Array? [solved]

Basic Algorithm Scripting : Mutations : have to convert to Array? [solved]
0

#1

I’m currently stuck at this challenge, my solution is as follows :

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

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

I don’t see any error in this, but the curriculum does not let me pass the challenge. I have a peek at ‘Get a hint’ which suggested something like converting the string to array, but do i have to?


#2

Your solution is case-sensitive.


#3

No, the first thing i do is convert all the element to lower case, pay attention to the first line below function mutation(arr)


#4

str.toLowerCase()
toLowerCase() does not affect the value of the string str itself.


#5

You are attempting to, but it isn’t doing what you think it is. Look at the documentation for toLowerCase().

(Recall that strings are immutable.)


#6

Ah yes, thank you. Solved.