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 AJAX Concepts Finish the AJAX Request

William Tunna
William Tunna
2,946 Points

requesting a XMLHttpRequest and assigning it to a variable with 'let'

When I'm assigning a variable to a new XMLHttpRequest, I get a syntax error if I were to use this for example:

let request = new XMLHttpRequest;

However, when I corrected this to:

var request = new XMLHttpRequest;

Everything worked fine. How come you can't use let to assign a variable in this case?

1 Answer

Steven Parker
Steven Parker
229,608 Points

This course was likely developed before ES2015 syntax was in common use.

If all of the video examples in a course use "var", then stick with 'var" for the quizzes and challenges.