In some case check was fail

Tell us what’s happening:
I make my own logic in this lesson but didn’t quite right. I don’t know what was the problem, I’m my head I already do check them one by one.

Your code so far

function mutation(arr) {
let n = 0;
let arr1 = arr[0].toLowerCase();
let arr2 = arr[1].toLowerCase();

for (let i = 0; i < arr1.length; i++){
  for (let j = 0; j < arr2.length; j++){
    if (arr1[i] == arr2[j]){
      n = n + 1;

if(n == arr2.length){
  return true;
return false;

mutation(["hello", "hey"]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Mutations

Link to the challenge:

Okay, i know what the problem is, but still idk what how to do it. The problem when i meet 2 or more same letter example hello or floor they count in. How to skip that?

1 Like

I might suggest you consider the logic again. The n variable is the one giving you problems… And you don’t need it. - this method gives you the index position of one string (or letter) inside another… or -1 if it doesn’t match. Can you see a way that can help?

Another hint: you are not limited to returning at the end of a function. If you’re inside a loop and a condition indicates, you can return from within the loop.
Instead read this

1 Like

Thank you mate, and the website very helpful too.