Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading