Initial, completed simple book exercise

This commit is contained in:
NetMan 2024-01-27 17:05:20 +01:00
commit 2327646379
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
function Book(title, author, pages, read) {
this.title = title;
this.author = author;
this.pages = pages;
this.read = read;
this.info = function() {
return `${title} by ${author}, ${pages} pages, ${(read) ? "read" : "not read yet"}`;
};
}
const myBook1 = new Book("The Hobbit", "J.R.R. Tolkien", 295, false);
const myBook2 = new Book("Pan Tadeusz", "Adam Mickiewicz", 692, true);
const myBook3 = new Book("Quo Vadis", "Henryk Sienkiewicz", 563, false);
console.log(
myBook1.info(),
myBook2.info(),
myBook3.info()
)