Not work “mutation([“hello”, “hey”]) should return false” but everyone else is working.
function mutation(arr) {
var test = arr[0].toLowerCase();
var tar = arr[1].toLowerCase();
for(i = 0;i < tar.length;i++){
if (test.indexOf(tar[i]) < 0){
return false;
}else{
return true;
}
}
}
mutation([“hello”, “hey”]);
Instead indexOf the whole word, do it but for every letter of tar[1]. You can use method charAt(i) where for “i” you loop through every individual letter.
Hello I have a problem on this challenge… So I’m here to ask for help, here you can see my code :
function mutation(arr) {
for(let i=0; i<arr[0].length;i++) {
for(let j=0; j<arr[1].length;j++) {
if (arr[i]!==arr[j]) {
return false;
} else {
return true;
}
}
}
}
mutation([“hello”, “hey”]);
This is works for all the cases where the result should be true but not where it should be false… I read some solutions about it but I don’t understand what is wrong with my code if someone can help me please… Thank you
You have opened a thread of your own, you don’t need to comment on other threads after that, it will also help because if you post on one place only you will also have answers on one place only