The current task;
Determine whether the first string in the array contains all the letters of the second string.
For instance, ['hello', 'Hello'] should result in true as all letters from the second string are found in the first, regardless of case.
If we consider ['hello', 'hey'], the answer would be false due to the absence of the letter 'y' in 'hello'.
Lastly, looking at ['Alien', 'line'], the expected outcome is true as every letter in 'line' is present in 'Alien'.
Here's a code snippet I've tried that isn't giving the desired result;
function mutation(arr) {
if (arr[0].toLowerCase().indexOf(arr[1].toLowerCase()) >= 0){
return true;
}else{
return false;
}
return arr;
}
mutation(['hello', 'hey']);
I'm seeking an explanation for why this solution doesn't work. Just understanding is required, not a direct answer. Thank you!
Appreciate your help