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