Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Arrays Methods: Part 2

George Kuka
George Kuka
2,673 Points

Task 1 no longer passing?

EDIT : Duh, was missing a ) to close the sort function, my bad!

I'm having an odd issue where randomly I'll get to say step two of a problem and when I goto check it, it says "Oops! It looks like Task 1 is no longer passing". If I comment out the code I changed for Task 2, it passes? Anyway it won't let me pass Task 2 of Methods Part 2 in JS Array course. Here's my code, I can't seem to figure it out...

<h1>JavaScript Foundations</h1>
    <h2>Arrays: Methods Part 1</h2>
    <script>
      var saying1 = ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"];
      var saying2 = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog's", "back"];
      saying1.reverse();
      saying2.sort( function(a, b) { return a.length - b.length; };
    </script>

I had the same problem in an earlier JS Challenge and fixed it by refactoring the code, but don't know where to go from this. Any help is appreciated.

1 Answer

George Kuka
George Kuka
2,673 Points

Make sure you close your sort function after the function =)