Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Foundations Arrays Methods: Part 2

Kirill Bondar
Kirill Bondar
8,930 Points

Don't work the challenge

Hi, i think my code is right, because i test it in Chrome console. saying2.sort(function(a,b){ return a.length >= b.length; }); But in this challenge i get the error.

1 Answer

Simon Klit
Simon Klit
1,686 Points

Hi Kirill,

A bit strange that your code doesn't work. Testing it for myself, I get identical results using your code, and the one below. Perhaps a JS Guru will come around and point out the issue, or maybe the Code Challenge only accepts this solution.

Either way, this should work:

saying2.sort(function(a,b) { return a.length - b.length });

Cheers!

Kirill Bondar
Kirill Bondar
8,930 Points

Thanks a lot. Your code is working)