Demo: Add Patrons and Books to the Library Class1:58 with Ashley Boucher
Try out the `addPatron()` and `addBooks()` methods we wrote in this demo.
Great work on creating the add book and 0:00 add patron methods inside the library class. 0:02 In this video we're going to test out these methods. 0:05 We'll call them on our library object, and 0:07 then use Chrome's dev tools to take a look at how that library object has changed. 0:09 You'll notice I attached another work space to this video. 0:13 This new one has the completed add book and 0:16 add patron methods added to the library class. 0:18 Open up the work space and let's get started. 0:21 I'm gonna head to my index.html file. 0:24 The book, patron and library objects we created previously are still there. 0:27 We'll use these objects now. 0:31 Since we already have a book object created, we can try 0:33 adding it to the library objects book property using our new addBook method. 0:36 So let's call the method on our library object. 0:41 Don't forget we have to pass in the book object we're adding to the addBook method. 0:46 Now let's log the library object to the console to see if the book object is now 0:52 in the book's array. 0:56 Let's save and check out the console. 1:02 Perfect. 1:10 Our library object is here. 1:10 Let's click this little arrow to see what's inside. 1:12 We can see the books and patrons properties each on their own line. 1:15 And it looks like the book object was successfully added to the book's property. 1:19 Let's click this arrow to look more closely. 1:24 Yep, we can see all the correct data is here, that's great. 1:26 Let's head back to the work space and do the same with our add patron method. 1:29 I'll call the method to add patron right under the method call to add book. 1:33 Now I'll save and preview again. 1:44 Let's click into the library object. 1:47 It looks like something has populated the patrons property. 1:49 If we dial down into it, 1:52 we can see the patron object with the correct properties and values. 1:53
You need to sign up for Treehouse in order to download course files.Sign up