Caty1121 / Library

Odin project JS exercise

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library

Library

Odin Project's JS track Library project

The Constraints:

  • If you haven’t already, set up your project with skeleton HTML/CSS and JS files.
  • All of your book objects are going to be stored in an array, so add a function to the script (not the constructor) that can take user’s input and store the new book objects into an array. Your code should look something like this:
  • Write a function that loops through the array and displays each book on the page. You can display them in some sort of table, or each on their own “card”. It might help for now to manually add a few books to your array so you can see the display.
  • Add a “NEW BOOK” button that brings up a form allowing users to input the details for the new book: author, title, number of pages, whether it’s been read and anything else you might want. How you decide to display this form is up to you. For example, you may wish to have a form show in a sidebar or you may wish to explore dialogs and modals using the tag. However you do this, you will most likely encounter an issue where submitting your form will not do what you expect it to do. That’s because the submit input tries to send the data to a server by default. This is where event.preventDefault(); will come in handy. Check out the documentation for event.preventDefault and see how you can solve this issue!
  • Add a button on each book’s display to remove the book from the library. You will need to associate your DOM elements with the actual book objects in some way. One easy solution is giving them a data-attribute that corresponds to the index of the library array. Add a button on each book’s display to change its read status

About

Odin project JS exercise


Languages

Language:JavaScript 47.4%Language:HTML 26.6%Language:CSS 26.0%