Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

338
Vistas
The Odin Project - Library project - issues with objects

I'm currently working on the The Odin Project's, Library project.

Here's the code at the moment: https://codepen.io/donatcs/pen/eYepQLz

Here's only the JS code:

class Book {
    constructor(title, author, pages, isRead) {
        this.title = title.value;
        this.author = author.value;
        this.pages = pages.value;
        this.isRead = isRead.value;
    }
}

let myLibrary = [];


        const addBook = (event)=>{
            event.preventDefault();  
            
            let books = new Book (
                title =  this.title,
                author = this.author,
                pages =  this.pages,
                isRead = this.isRead)
             
            myLibrary.push(books);
            
            console.log('added' , {myLibrary} );
            let pre = document.querySelector('#bookz table');

            pre.textContent += (JSON.stringify(myLibrary, '\t', 2));

            localStorage.setItem('MyLibrary', JSON.stringify(myLibrary));
        }
        document.addEventListener('DOMContentLoaded', ()=>{
            document.getElementById('btn').addEventListener('click', addBook);
        });

It's still in the very early stages so I know the code looks bad and the functionality is not correct.

Here is the Project with the requirements: https://www.theodinproject.com/paths/full-stack-javascript/courses/javascript/lessons/library

I need help with displaying the Books correctly.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda