Tell us what’s happening:
Hi everyone,
I’ve been trying to find out where was my mistake but I can’t find it.
My code works for every differents case except for :
mutation([“Hello”, “Hey”]);
The point of the exercise is to compare the first and second string inside the array and see if they have the same letters so far. If one is different it has to return false, otherwise, true.
Thank you for ur help !
Your code so far
function mutation(arr) {
var arr1 = arr[0].toLowerCase();
var arr2 = arr[1].toLowerCase();
for(let i = 0; i<arr2.length ; i++){
if(arr1.indexOf(arr2[i])< 0){
return false;
}
return true;
}
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
.
Link to the challenge:
I can’t since it’s my first post
Edit: correct some mistakes about my explaination