// Free Code Camp exercise: Mutations: Check every letter in array[1] to see if present in array[0];
//Looks like the while loop doesn’t increment correctly (and maybe that’s not all). Can anyone see why?
function mutation(array) {
var x;
var p = 0;
while (p < array[1].length) {
x = array[0].toLowerCase().indexOf(array[1][p].toLowerCase();
// x checks an all-lowercase array element 0 for the index of letter p (variable) in array element 1
if (x < 0) {
return false;
}
p = p + 1;
return true;
}
}
//Tests
mutation(["hello", "hey"]);
mutation(["Belay", "ben"]);