Tell us what’s happening:
My problem is that the array works for all values that are true but it doesnt return the false, I checked the solution after i wrote this and it is almost exactly the same, the only difference is that they store the array values in 2 different containers. What’s wrong with my code?
Your code so far
function mutation(arr) {
// My solution is below, i'm not sure why it won't work
//Lower case everything
arr.map(function(x){return x.toLowerCase();});
//Iterate through the array[1] and check if it exists in arr[0] if it does, return true, else return false
for (var j = 0; j < arr[1].length; j++){
if (arr[0].indexOf(arr[1][j]) != -1)
return true;
}
return false;
}
mutation(["hello", "hey"]);
Link to the challenge:
https://www.freecodecamp.org/challenges/mutations