Hey guys, I can’t seem to satisfy most of the conditions and I can’t figure out why.
Here is my code for the Mutation functions
function mutation(arr) {
var word1;
var word2;
word1 = arr[0].split('');
word2 = arr[1].split('');
word1 = word1.sort();
word2 = word2.sort();
for (var i = 0 ; i < word2.length; i++){
if(word1.indexOf(word2[i]) !== -1 ){
return false ;
}
else {
return true;
}
}
}
mutation(["Alien", "line"]) ; //returns false when it should return true
Can someone tell me where I am screwing up in my code? Thanks!