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!

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

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>
      var saying1 = ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"];
      var saying2 = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog's", "back"];
      saying2.sort( function(a, b) { return a.length - b.length; };

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 =)