Tell us what’s happening:
I use the procedure of IndexOf to return the true or false values. However the code is failing on certain tests>
mutation(["hello", "hey"])
should return false.
Passedmutation(["hello", "Hello"])
should return true.
Failed mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])
should return true.
Passedmutation(["Mary", "Army"])
should return true.
Passed mutation(["Mary", "Aarmy"])
should return true.
Failed mutation(["Alien", "line"])
should return true.
Failed mutation(["floor", "for"])
should return true.
Passedmutation(["hello", "neo"])
should return false.
Passedmutation(["voodoo", "no"])
should return false.
Failed mutation(["ate", "date"]
should return false.
Passedmutation(["Tiger", "Zebra"])
should return false.
failed mutation(["Noel", "Ole"])
should return true.
Your code so far
function mutation(arr) {
var value = arr[0].toLowerCase();
var test = arr[1].toLowerCase();
console.log(value,test);
for (var i = 0; i < value.length; i++) {
console.log(test.indexOf(value[i]) < 0);
if (test.indexOf(value[i]) < 0) return false;
}
return true;
}
mutation(["hello", "hey"]);
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
.
Challenge: Mutations
Link to the challenge: