emoji: "📗",
author: "George Orwell",
title:"1984",
format:"Paperback",
price:"$9.99",
getTemplate: function() {
const { id, emoji, title, author, format, price} = this;
return `<div class="book">
<div class="emoji">${emoji}</div>
<div class="title">${title}</div>
<div class="author">${author}</div>
<div class="format">${format}</div>
<div class="price">${price}</div>
<button id="cart-${id}">Add to Cart</button>
</div>`
}
}
document.getElementById("books").innerHTML = book.getTemplate();
// update the title and the author of the book when the button is clicked
// note you will need to rerun the getTemplate method once it's updated
document.getElementById(`cart-${book.id}`).onclick = function() {
};
const book = {
id: 1,