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 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
229,788 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.