Tell us what’s happening:
My code pass all the tests exept for this one
// running tests
mutation(["Mary", "Aarmy"])
should return
true
. // tests completed // console output false i need to know way it did not push the index of the letter y to the letters array
Your code so far
function mutation(arr) {
let string1 = [],
string2 = [],
letters = [];
for (let i=0; i<arr[0].length; i++) {
string1.push(arr[0][i].toLowerCase());
}
for (let j=0; j<arr[1].length; j++) {
string2.push(arr[1][j].toLowerCase());
}
for (let k=0; k<string1.length; k++) {
if (string1.includes(string2[k])) {
letters.push(string1.indexOf(string2[k]));
}
}
return letters.length === string2.length;
}
console.log(mutation(["Mary", "Aarmy"]));
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 11; Nokia 3.4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Mobile Safari/537.36
Challenge: Basic Algorithm Scripting - Mutations
Link to the challenge: