What is wrong with this code? Can’t solve the ones that should return false. Adding an else with “return false” is not working.
This is the test without return false:
// running tests
mutation(["hello", "hey"])
should return false.
mutation(["hello", "neo"])
should return false.
mutation(["voodoo", "no"])
should return false.
mutation(["ate", "date"]
should return false.
mutation(["Tiger", "Zebra"])
should return false. // tests completed
And if I add the else I fail with the ones that need to return true…
Your code so far
function mutation(arr) {
for(var i = 0; i < arr.length; i++){
for (var j = 0 ; j < arr[i].length; j++){
var letras = arr[i][j];
var lC = letras.toLowerCase();
if (arr[0].indexOf(lC) > 0 ) {
return true;
}
}
}
return arr;
}
mutation(["Mary", "Army"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36
.
Challenge: Mutations
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations