Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops For Loops

Why teach global impurity?

A for loop is great, but why teach to hold global variables outside of the code block or a function? I understand simplicity, but if you teach it correctly from the start, and just tell them why later, it will be easier to understand later.

Otherwise put, we learn practices that we then have to unlearn later because they're not best practices. Why not start with best practices up front and make it an easy rule. Then when you explain why, there is no massive unlearning and frustration.

Just saying.

1 Answer

Steven Parker
Steven Parker
216,016 Points

:point_right: This might just be a version issue.

Many of the courses were developed before ES2015 was widely adopted. To my knowledge, those released since all adhere to the principles you describe.

As the existing courses get revised, I would expect everything in the library will eventually get updated and conform also.