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) Programming AJAX AJAX Callbacks

d4rk5un
d4rk5un
2,771 Points

Create callback function challenge

'Create callback function' challenge won't pass if you use an arrow function.

2 Answers

Steven Parker
Steven Parker
231,198 Points

Arrow functions are not intended to be used instead of conventional functions in all situations, and in fact there are some situations where they are specifically not allowed (they cannot be used as constructors, for example). Another difference that often causes confusion is that they don't define internal variables such as "this" like conventional functions do.

For a complete description of the differences, see this MDN page.

d4rk5un
d4rk5un
2,771 Points

Thank you for your answer.

I am aware of what you are saying, the thing is that I can use the arrow functions with the previous examples, but they the tests won't pass if I use them in this particular exercise.

Cheers! K.

Steven Parker
Steven Parker
231,198 Points

Right, and that's probably because this time the function you're passing it to is dependent on one or more of those factors that only conventional functions provide. If you check the documentation for the API, it would hopefully include a warning that arrow functions can't be used there.