commit 23276463793adf3b8fc3e6a068e733ac8c32e637 Author: NetMan <13informatyka14@gmail.com> Date: Sat Jan 27 17:05:20 2024 +0100 Initial, completed simple book exercise 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