Demo: Checking Out and Returning a Book2:07 with Ashley Boucher
Now that we've added the `out()` setter method and refactored our `checkOut()` and `returnBook()` methods, let's see how they work in this demonstration.
Now that you've refactored the checkout and 0:00 return book methods, lets head back to Workspaces to demo them. 0:02 If you need it, I've attached a new Workspace to this video that includes 0:05 the most up to date code. 0:09 Once you've got your Workspace open, navigate to the index.html file. 0:10 I'd like to see how our checkout and 0:15 return book methods are working with the addition of our out setter method. 0:17 So first, let's log the patron object to refresh our memory about what's inside. 0:21 Now let's save, preview, and use our dev tools to check out the console. 0:30 Let's click this little arrow to dial down into the logged patron object. 0:35 As you can see, the patron's name and email address are there and 0:39 the current book property is set to null. 0:42 Let's go back to work spaces and have this patron check out a book so 0:45 this current book property is populated with something. 0:48 I'm gonna call the checkout method on the patron object and 0:52 pass in the book object we created here. 0:55 After saving this and heading back to our console, we should be able to see 1:03 the book object as the value for patron's current book property. 1:07 Now, when we dial into our patron object, 1:13 we can see the book object in the current book property. 1:14 If we click on into it, 1:18 we can also see that our set of method worked just as we wanted it to. 1:19 The outback end property is set to true and 1:23 even the due date property was populated. 1:26 All right, now that we've checked the book out, let's return it to the library. 1:28 Right below the checkout method call, 1:33 we can call the return book method on the patron object. 1:34 Let us keep this patron log after the returnBook method and 1:39 also add a console.log for the book object. 1:42 All right, now save and head back to the browser. 1:49 As expected, the patron's currentBook property is back to null. 1:52 And inside the Book object, the dueDate property is null, once again, and so 1:56 is the patron property. 2:00 The _out backend property is set back to false. 2:02 Okay, great work on this, let's keep going. 2:05
You need to sign up for Treehouse in order to download course files.Sign up