Why is my code not working? Basic Algorithm

Tell us what’s happening:
Describe your issue in detail here.

   **Your code so far**

function mutation(arr) {
  
   let a = arr[0].toLowerCase().split("")
 
   let b = arr[1].toLowerCase().split("")

for(let j = 0; j < a.length ; j++) {
  for (let i = 0; i < b.length ; i++) {
    
         if(b[i] !== a[j]){
            arr = false
            
       
         }
         else{
            arr = true
         
         }
     
 }

}

return arr
}


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

Challenge: Mutations

Link to the challenge:

Why does this not work as well?

function mutation(arr) {

   

    let a = arr[0].toLowerCase()

  

    let b = arr[1].toLowerCase().split("")

 

   for (let i = 0; i < b.length ; i++) {

     

          if(a.indexOf(b[i]) == -1){

             arr = false

                     

          }

          else{

             arr = true

          

          }

      

  }

   return arr

 }

 

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

Look careful what the challenge requires of you and what your code is actually doing. You want to loop thru every letter of the second word, and make sure such letter is contained in the first word. Your code does not “remember” if a letter is present in the first string, it just goes letter by letter and returns whether they match. In the end, you return your last comparison(the last two letters compared), instead of returning whether all letters are contained(or at least one is missing)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).