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

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