Basic Algorithm Scripting - Mutations

Tell us what’s happening:
I feel like there is a problem with the tutorial here. I think my solution is perfect and I can’t find any fault whatsoever, still it doesn’t accept my code.

Your code so far

function mutation(arr) {
  const firstword = arr[0].toLowerCase;
  const secondword = arr[1].toLowerCase;
  for (let i=0;i<secondword.length;i++){
    if(firstword.indexOf(secondword[i])<0) return false;
}
  return true;
}

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/111.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

I don’t understand. I get proper output now when I did console.log

What did I do wrong, can you please elaborate a bit?

The two codes are same, except the addition of two console.logs, outputting firstword and secondword. I fail every test case that requires false as an output.

Aah understood!! Thanks a lot, @camperextraordinaire.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.