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 AJAX Basics (retiring) jQuery and AJAX The Office Status Project Revisited

Kenneth Kim
Kenneth Kim
3,795 Points

Arrow functions are not working on the previous quiz. Please Help.

Hi I would like to know why arrow functions does not work in replace the traditional way of declaring anonymous functions? For example:

// traditional way
$.get("footer.html", function(response) {
  $('#footer').html(response);   
});

// arrow functions
$.get("footer.html", (response) =>  {
  $('#footer').html(response);   
});

The quiz does not mark the answer correct if I did the 2nd one. This thing happens to me a lot specially during the jQuery part of the track.

Any explanation will certainly help me understand. Thank you in advance.

1 Answer

Steven Parker
Steven Parker
229,982 Points

This course was developed before arrow functions were part of the language.

Judging from the download files, this course is from 2014, but arrow functions were introduced in ES2015. You might make a request for the challenges to be updated to Support, or maybe even report it as a bug.

But also bear in mind that arrow functions can't always be used in place of conventional functions, for example, where you need to access "this". In some challenges this may be a factor. Be sure that you aren't trying to use them in situations where they just wouldn't work.