Welcome to the Treehouse Community
Looking to learn something new?
Sheila Babadi5,241 Points
this.name and this.state
I don't quite understand why it's necessary and/or better to use this.name and this.state in the function printMyCityAndState (or whatever it was called). If it were just "name" and "state", wouldn't the correct values still be printed if you were calling it on a specific instance of that object?
P.S. You forgot the Portland Thorns!!!
Steven Parker216,083 Points
Remember that the method is being defined inside the constructor for City.
Inside the constructor, the names "city" and "state" refer to the arguments passed to the constructor, not to the instance variables they get assigned to. So to make sure the method uses the instance variables, the variable names must be prefixed with "this.". Also, the contents might be different if the arguments were undefined when the constructor was called.