Tell us what’s happening:
I wasn’t able to understand, how the commented part works !??
I want some detailed explanation of that line.
Please help!
Your code so far
function mutation(arr) {
const test = arr[1].toLowerCase();
const target = arr[0].toLowerCase();
for (let i = 0; i < test.length; i++) {
if (target.indexOf(test[i]) < 0) return false; // < 0 This Line
}
return true;
}
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/110.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Mutations
Link to the challenge: