- Welcome back.
Here's how I solved the create a new object type talent.
It starts in index dot HTML
where I import a new file called book dot JS
as a module.
Book dot JS contains a new class called book.
In the constructor for book,
I've captured all the properties I want to use
to describe each of my books.
So here we have title, author, ISBM number,
published year, page number, current page.
That would be where I am in the book
and finally read status.
And all of these properties are populated down here
as we always do in a class.
Then we have two methods.
Update current page which grabs a new current page value
and passes it into the current page property
and update red status which grabs a new red status value
and pass it into the red status property.
Finally, we export the default book
so that is the class itself
and the classes then import it as book in script JS.
Here if we scroll down a bit,
I've set up all the different books.
Now to help myself out,
I started out by setting up a comment that lists
out the order of the different properties
so I don't forget.
So here we have title, authorized band, pub year,
et cetera, et cetera, et cetera.
And then to set up the different books
I just literally filled them out.
So I created a camel case naming convention here,
just to, so that each name is recognizable
to me based on the title of the book.
So here we have surveillance capitalism
and that is the age of surveillance capitalism.
Then we have the author name, the ISBM number,
the year I chose to have as a string because I wanted to
maybe interpret it later using one of the many date methods
and the date methods like to work with strings.
Then I grab the current page number
and the full page number
and the red status should be either finished
or reading or haven't started yet or something like that.
So I'm just passing in a straight up string.
Then I just console log out the objects
that I can look at it later.
And I've done this with five different books
so that we have some different content to work with.
In the browser, it looks like this.
First, we have the original code
that's for the everyday backpack.
That was what was in the exercise files already.
Then I have these five book objects and if I open them,
you can see each of them has nice data that I can then dig
into further and get more information from.
And I now have five functional objects
with their own methods that I can work with, update,
get information from and just do whatever I want with.