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

Brett Campbell
Brett Campbell
14,077 Points

Task 2

I have no idea where I am going wrong. I currently have Task 2 looking like this: saying2.sort(toString.length). Any hints??

2 Answers

Chris Dziewa
Chris Dziewa
17,781 Points

You need to pass in a function to the sort method that returns a negative number, 0, or positive number by comparing two items in your array. This function will replace what you have within parentheses. If you would like I can share a passing answer.

Brett Campbell
Brett Campbell
14,077 Points

I figured it out! Thanks for the response though!

Chris Dziewa
Chris Dziewa
17,781 Points

That's the best way. Good job!