What is wrong in my logic mutations problem in js

Hi guys ,
I am trying to solve the mutation problem without using indexOf().

can u point out the problem in logic or exiting for loop etc
My code

function mutation(arr) {
    let isTrue=false;
    for(var i=0; i<arr[1].length; i++) //iterate elements in second string 
    {   
        for(var j=0; j<arr[0].length; j++) //iterate elements in first string 
        {
           
            if(arr[1][i].toLowerCase()===arr[0][j].toLowerCase())
            {
               
                isTrue=true;
                
            }
         
       }
     

    }
    return isTrue;
  }

link to challenge

what’s the link to the challenge?

You initialise your isTrue variable with false, then iterate over the letters. As soon as it happens only once that a letter can be found in both words, isTrue becomes true (and stays like that). The only case in which your function would return false is when both words don’t share any letters, like this:

mutation(["abc", "de"]);
1 Like