Hi guys,
I don’t understand why my code doesn’t work for the first case but works with all the others…
Thanks in advance for you help
Your code so far
function mutation(arr) {
let firstElementArr = arr[0].split('')
console.log(firstElementArr)
let secondPart= arr.slice(1, firstElementArr.length).join('').toLowerCase()
console.log(secondPart)
let secondPartArr = secondPart.split('');
console.log(secondPartArr)
for (let i=0 ; i<=secondPartArr.length ; i++){
if(firstElementArr.indexOf(secondPartArr[i])>=0){
return true
}
return false
}
}
console.log(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/83.0.4103.61 Safari/537.36
.
Challenge: Mutations
Link to the challenge: