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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![William Tunna](https://secure.gravatar.com/avatar/7ce620e1e5b316c01fd51335671ad979?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
William Tunna
2,946 Pointsrequesting 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](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThis 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.