It's about a basic algorithm challenge, in which the user has to 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, e.g.:
["hello", "Hello"]
should returntrue
.["Alien", "line"]
should returntrue
.
So far, I've tried this:
function mutation(arr) {
var value1 = arr[0].toLowerCase();
var value2 = arr[1].toLowerCase();
for (var i = 0; i < value2.length; i++) {
if (value1.indexOf(value2.charAt(i)) !== -1)
return true;
else
return false;
}
}
}
mutation(["hello", "hey"]);
While passing the value mutation(["hello", "hey"])
, it isn't returning false
.