I have the following JavaScript function using which I want to check if the first element of the array called mutation
contains all the letters of the second element.
function mutation(arr) {
let test = arr[1].toLowerCase();
let target = arr[0].toLowerCase();
let split = test.split('');
split.forEach((elem)=>{
if(target.indexOf(elem) < 0 ) {
return false;
}
});
return true;
}
mutation(["hello", "hey"]);
Now it should show me boolean false
because letter y does not exist in hello word. but it's doesn't.
Is there anything I am doing wrong?