OK, forum folks, I can’t figure out what’s going wrong with my code here. I’m sure it’s something obvious. The only test that is failing is the first one (does “Hello” have all the letters in it that “Hey” does?), which makes me think I have an off-by-one error somewhere, but I can’t see it.
function mutation(arr) {
//lowercase both strings and separate them out
let sampleString = arr[0].toLowerCase();
let testString = arr[1].toLowerCase();
for (let i=0; i < testString.length; i++) {
if (!sampleString.includes(testString[i])) {
return false;
} else return true;
}
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Mutations
Link to the challenge: