Https://www.freecodecamp.org/challenges/mutations

Https://www.freecodecamp.org/challenges/mutations
0.0 0

#1

My code is running except for mutation([“Mary”, “Army”]) should return true and
mutation([“Mary”, “Aarmy”]) should return true.

Can someone please explain why this is happening?

My code so far

function mutation(arr) {
 a=arr.slice(0,1); var a_str  = a.toString();  a_arr  =  Array.from(a_str);  
 b=arr.slice(1,2); var b_str  = b.toString();  b_arr  =  Array.from(b_str);
 var  flag=0; 
  
    for(var  i=0;i<b_arr.length;i++){  
      for(var  j=0;j<a_arr.length;j++){
        if(b_arr[i]==a_arr[j]){
          flag+=1;
        }
      }
    
          }
  
  if(flag>=b_arr.length){
      return  true;
    } else  return  false;

}
mutation(["voodoo", "no"]);

#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.