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 Foundations Variables Hoisting

Ben Lee
Ben Lee
9,791 Points

I Need Help!

Hello Everyone,

I am new to Treehouse and I just started JavaScript. I am working on this Hoisting challenge and can't figure out how to correctly alter the code so that it follows the best scoping practices. Can someone point me in the right direction?

2 Answers

David Jarrin
PLUS
David Jarrin
Courses Plus Student 11,182 Points

think of how you declare the variable inside and outside the if statement, when do you use the var deceleration and when should you not?

Ben Lee
Ben Lee
9,791 Points

Thank you David. I got it :)