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 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,999 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.