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 Practice Object Interaction Checking Out and Returning a Book Solution: A Better Way With Setter Methods

Tomasz Grodzki
Tomasz Grodzki
8,130 Points

Why there's no change in dueDate, book and currentBook properties?

I have written some code and I saw that some properties aren't changing.

But well... In code that we get from Ahley, properties also aren't changing. Take a look at console log... At Book's dueDate and patron properties and Patron's currentBook property after checkOut(). There's still 'null' value. Why is that?

https://w.trhou.se/v7tywmxn4e

1 Answer

Steven Parker
Steven Parker
231,248 Points

You're probably examining live references in the dev tools, and the states have already changed back before you can examine them.

Try logging out the specific property you want to see changing, for example:

  patron.checkOut ( book );
  console.log ( book.patron );   // log the specific property to see it set
  patron.returnBook ( book );
  console.log ( book.patron );   // and now cleared again
Tomasz Grodzki
Tomasz Grodzki
8,130 Points

Exactly, that was a problem. Thanks for help!