I am trying solving a challenge called Mutations
from Basic Algorithm Scripting section on freeCodeCamp.com Curriculum.
link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations
I checked my code many times but I do not know what are the mistakes that in my code.
My code so far:
function mutation(arr) {
let arr0 = arr[0].toLowerCase();
let arr1 = arr[1].toLowerCase();
let target0 = arr0.split("");
let target1 = arr1.split("");
let array = [];
array.push(target0);
array.push(target1);
for (let i = 0; i < target1.length; i++) {
if (target0.indexOf(target1[i] >= 0)) {
return true;
}
else {
return false;
}
}
return array;
}