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

Kuladej Lertkachonsuk
seal-mask
.a{fill-rule:evenodd;}techdegree
Kuladej Lertkachonsuk
Full Stack JavaScript Techdegree Student 3,175 Points

Confused -- Why didn't the name property be 'Rainbow Dash'.

the instructor only used Print function once. Shouldn't the name all be 'Rainbow Dash'. Can anyone explain me the principle behind? Thank you very much.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It did become "Rainbow Dash". Inside the print function he changes the name and age of the person and those are then added to the DOM. Take a look around 4:21. He changes the name and then appends a new paragraph to the page with the new name.

Hope this helps! :sparkles:

edited for additional information

We have a line that adds a paragraph to the DOM with the original name. Then we change the name. Then we add a new paragraph with the new name.

Jessica Stocks
Jessica Stocks
2,831 Points

Can you explain the additional information? Even after watching the video I don't understand why the printed message doesn't have the name Rainbow Dash in both person.name fields.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Jessica Stocks ! LetΒ΄s try a more "real life" type example. I have a passport and on that passport is my name "Jennifer Nordell". If I get married tomorrow, legally speaking, my name will change. But my passport doesn't know that. When I pick up my passport and look at it, it will still say "Jennifer Nordell". In order to get a passport with my new name, I must first talk to the issuing authority and send in the paperwork for a new passport with the correct last name. The passport was printed before my name was changed.

This is essentially the same thing. On line 14, we print out the person.name property. At the time this is printed it has a value of "Sarah". On line 16, we change the name. When we now print out person.name, it will hold the value of the new name.