function mutation(arr) {
var arr1 = arr[0].toLowerCase().split('');
var arr2 = arr[1].toLowerCase().split('');
var temp = false;
for(var i=0; i<arr2.length; i++){
temp = false;
for(var j=0; j<arr1.length; j++){
if(arr2[i] === arr1[j]){
temp = true;
}
}
if(temp === false){
//all the letters in the first word didn't match
break;
}
}
return temp;
}
mutation(["hello", "Hello"]);
No comments:
Post a Comment