19 lines
538 B
JavaScript
19 lines
538 B
JavaScript
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()
|
|
) |