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 and the DOM (Retiring) Getting a Handle on the DOM A Simple Example

Is it a good practice to name the variable the same as the Id or will it cause refactoring problems?

none

1 Answer

jobbol
seal-mask
.a{fill-rule:evenodd;}techdegree
jobbol
Full Stack JavaScript Techdegree Student 17,885 Points

Talking about this part?

var myHeading = document.getElementById('myHeading');

It's perfectly fine. I believe this approach makes readability easier.

Like you said though, if you do choose to refactor and give myHeading a different name. You will have to dig through your HTML and change that one as well. But on the other hand, you'll have a hard time reading your code if you have to decipher which variable belongs to what element in your html.

thanks