Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

336
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda