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.
Could you just as easily have used var name instead of const name and made sure that name was local to the function?
I thought variable names are local to functions and therefore you can declare and use the same names within different functions without affecting each other. In that case, it would seem that the error is simply forgetting to use a declaration of a new variable. So the mistake of forgetting to do so would just as easily happen whether you use var or const.
In that case, it seems like a better example of the use of const would be in creating the global variable. Or am I misunderstanding?
as far as i see you are telling it taxRate = 'mike'; so you will always get mike. But once you set a var inside you are creating a different object.