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

Brian Van Skiver
Brian Van Skiver
1,169 Points

I'm stuck

Not sure how to sort alpha and find the length. The video only shows sorting numbers

2 Answers

Brian Van Skiver
Brian Van Skiver
1,169 Points

I got it added a.length - b.length to my function

If you re-read the challenge, it's not asking you to sort alpha, it's asking you to sort by the length of the strings. So basically, you are sorting numbers. To get the length of a string, you can use the length property.