Tell us what’s happening:
This seems like a silly question, but could someone please explain why the code below doesn’t solve the problem? The only differences from “solution 1” in the challenge guide is I swapped the positions of return true
and return false
and changed the <
to >=
within the if
statement.
**Your code so far**
function mutation(arr) {
let test = arr[1].toLowerCase();
let target = arr[0].toLowerCase();
for (let i = 0; i < test.length; i++) {
if (target.indexOf(test[i]) >= 0) {
return true;
}
}
return false;
}
console.log(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/91.0.4472.164 Safari/537.36
Challenge: Mutations
Link to the challenge: