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++){
      return  true;
    } else  return  false;

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

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.