Tell us what’s happening:
I know the return keyword is the issue here, but I still feel like this code makes sense. I just don’t know how to get my return keyword out of the loop so it doesn’t end early.
Am I wrong? Is the solution truly to just take another approach or should I just think of a way to get rid of “return”?
Your code so far
function mutation(array) {
const arrayItem1 = array[0].toLowerCase();
const arrayItem2 = array[1].toLowerCase();
for (const letter of arrayItem2) {
if (arrayItem1.includes(letter)) {
console.log(letter)
return true
}
else {
return false
}
}
}
console.log(mutation(["hello", "hey"])) //false because first element should contain all letters of the second one
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Implement the Mutations Algorithm - Implement the Mutations Algorithm