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 Tracking Data Using Objects Accessing Object Properties

Confused - when do we change value in the code instead of replacing it in the object value?

As I'm new to programming that might be a silly question. I keep hearing that we should avoid repeating ourselves and try to be super clear when naming variables, etc. In this video when we change the name it got me thinking, how this might be applied. How do we keep track of these changes, would not that be confusing?

Stephen Aydt
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Aydt
Full Stack JavaScript Techdegree Student 5,577 Points

In the real world I would Imagine that something like chaniging your username or password would be a good use for this. I am just learning to program for the first time, but that's what I think.

2 Answers

Raffael Dettling
Raffael Dettling
32,997 Points

The best thing would be to declare them right at the start. But if you wanna change them afterwards some development programms like Visual Studio highlight specific variables through the entire code. So it´s easier to change them. :)

Thanks! Yeah, it was more a question for what's the best practice! I think it's clearer for me now.