This problem took me some time, and I’m curious if my solution is inelegant/inefficient. I would welcome any feedback, or suggestions for improvement.
function mutation(arr) {
var a = arr[1].toLowerCase().split('');
var b = arr[0].toLowerCase();
var i = 0;
while ((b.indexOf(a[i]) >= 0) && (i < a.length)) {
i++;
}
if (i === arr[1].length) {
return true;
} else return false;
}
mutation(["hello", "hey"]);
Thank you for the simplifying suggestions - as regards the includes() method, I was avoiding using it because the prompt refers to the indexOf() method, and I don’t think includes() is described anywhere in the course work up to this point.