Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Object Interaction!
You have completed Practice Object Interaction!
Preview
Join me in this demo to use the code we've written so far and see the inner workings of our new Library, Patron, and Book objects.
Arguments for Book Object
'Harry Potter and the Sorcerer\'s Stone', 'J.K. Rowling', '978-0439708180'
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Great job building out
those constructor methods.
0:00
Let's take a look at
what we've accomplished.
0:02
I've loaded up all the code we've
written so far into a workspace, and
0:04
attached it to this video so
you can follow along with what I'm doing.
0:08
If you prefer to use the workspace
you've already opened, that's fine too.
0:11
Inside the attached workspace, you
should see three files you've worked in.
0:15
Library.js, Book.js and Patron.js.
0:18
You'll also see an index.html file.
0:23
The html file is just for
testing purposes.
0:27
If you open it up you'll see
it's mostly empty except for
0:30
that I've used script tags to load
all of our individual class files.
0:32
At the bottom of the document
I included another script tag.
0:36
Inside this script tag we
can play with our code and
0:39
log our findings to the console.
0:41
Let's create a new library object and
log it to the console.
0:43
Now, to see what this variable contains,
we'll go ahead and preview
0:52
the index.html file by clicking this
preview button in the top right corner.
0:55
That opens the page in a browser.
0:59
Then, we'll right-click and use Chrome's
developer tools to see the console.
1:01
As you can see,
1:07
the library variable that's logged to
the console contains a library object.
1:08
We can see it has two properties,
books and
1:11
patrons, both of which are empty arrays.
1:14
This is all exactly as we expected.
1:17
Now let's go back and make book and patron
objects and check those out as well.
1:19
Now, I'm going to copy and
paste in the arguments for title,
1:28
author and ISBN for a book.
1:31
I've put these in the teacher's notes for
this video so you can copy and
1:33
paste them as well or enter your own.
1:36
Now let's create a patron object, Being
1:41
sure to pass in the arguments to
the constructor method for name and email.
1:46
Let's add two more console logs for
our new book and patron objects and
1:58
then head back to our browser,
refresh and check the console again.
2:02
Cool, looks great.
2:12
We can see our two new objects,
book and patron, and
2:14
see all of their properties and values.
2:17
Now that we've got some basic objects
working, let's move forward and
2:20
start adding some methods to our classes.
2:23
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up