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 JavaScript and the DOM (Retiring) Getting a Handle on the DOM Select All Elements of a Particular Type

Steve Seebart
PLUS
Steve Seebart
Courses Plus Student 11,897 Points

Using const and var in coursework

In the previous code challenge, the variables are declared with the var keyword. Changing to a construction with the const syntax also works, but both are accepted as correct. The coursework at this point (and in the workshop on variable declaration) suggests that var is deprecated and should be avoided. So--a little confused about how to proceed.

2 Answers

Yes it is that of course because this course has been made a couple years ago!

So, try to use let and const the most as you can and try avoiding using the var keyword.

const keyword: when you do not want the value of your variable to change let keyword:when you want the value to change

For example, you could select a button with the const keyword and target a list item in a list with the let keywod.

Happy Coding!

Steve Seebart
Steve Seebart
Courses Plus Student 11,897 Points

Sure, I understand the difference. I guess my concern was about the inconsistency in the courseware. Sounds like the vars are artifacts of stages that haven't been updated, not "gotcha" questions meant to help us more to the ES2015 standard.