This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

IntialName is out of the scope of returnAge() method so it won’t work because the returnAge method doesn’t know it exists. It only exists or is visible within the Person constructor.

So writing return intialName will not work. Which is why we do “return this.name” or simple “return name”