From 23276463793adf3b8fc3e6a068e733ac8c32e637 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Sat, 27 Jan 2024 17:05:20 +0100 Subject: [PATCH] Initial, completed simple book exercise --- simple-book-exercise/script.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 simple-book-exercise/script.js diff --git a/simple-book-exercise/script.js b/simple-book-exercise/script.js new file mode 100644 index 0000000..6fb9396 --- /dev/null +++ b/simple-book-exercise/script.js @@ -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() +) \ No newline at end of file