I run my code in Node.js (v10.17.0) on my local machine (Ubuntu 18.04.3 LTS) and it pass all of the test, but does not pass in freeCodeCamp. Any ideas?
Here is my code:
function mutations(arr) {
// change both strings to lowercase
str1 = arr[0].toLowerCase();
str2 = arr[1].toLowerCase();
// loop through each letter in 2nd string
for (var i = 0; i < str2.length; i++) {
//console.log(str2[i]); // TEST: verify each letter
//check if letter is in 1st string
if (str1.indexOf(str2[i]) === -1) {
return false;
};
};
return true;
};
console.log(mutations(["hello", "hey"]));
console.log(mutations(["Alien", "line"]));
console.log(mutations(["Hello", "hello"]));
console.log(mutations(["Mary", "army"]));
console.log(mutations(["ate", "date"]));
console.log(mutations(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]));