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.
I'm confused, we changed the value for (person.name), and when we print we see both values. Why? I come from Java OOP.
I learned OOP in Java. When I create an object called person. Instantiate the object with the name variable value of "Sarah". Then change it to "Rainbow Dash". Finally displaying the same sentence as in this example but in Java, I get ...
-- Hello, My Name is Rainbow Dash -- I live in the US -- But, I wish my name was Rainbow Dash
Now this prints out Hello my name is John.I live in US
But with Angular.js you can change the object property value quite easily.
Well since your declaring a variable you can simply just make it dynamic by prompting the User for their name or using a textbox to get the name and creating a new object property with the name.
person[name] = prompt("Whats your name? ");
return value is always a string