Codewars wont accept my code, what seems to be the issue?

Here's the problem

Here’s my code:

function friend(friends){
   let here =[];
  for (let i = 0; i < friends.length; i++) {        
        if (friends[i].length == 4){          
            here.push(friends[i]);                
        }   
       
    }
    console.log(here); 
}

friend([ 'Ace', 'Luffy', 'Zoro', 'Nami', 'Ussop' ]);

When I test my program it says:

expected undefined to deeply equal [ ‘Ryan’, ‘Mark’ ]

>Solution :

Your function should return the result, not print it out to the console. I.e., replace console.log(here) with return here.

Leave a Reply