diff --git a/src/objects.ts b/src/objects.ts index ef6298f..381d9c9 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -27,8 +27,8 @@ function createBook( genre: string ): Book { // write your code here... - - return {} as Book; // replace "{} as Book" with what you see is fit + let newbook : Book = {title: title, author:author,publishedYear,genre} + return newbook; // replace "{} as Book" with what you see is fit } // DO NOT CHANGE THE LINE OF CODE BELOW (you can use it for testing your code) @@ -51,7 +51,7 @@ const book = createBook( function printBookTitleAndYear(book: Book): string { // write your code here... - return ""; // replace empty string with what you see is fit + return book.title + " " + book["publishedYear"]; // replace empty string with what you see is fit } /** @@ -66,8 +66,10 @@ function printBookTitleAndYear(book: Book): string { */ function addPageCount(book: Book, pageCount: number): Book { // write your code here... - - return book; +// const newbook : Book = {title: book.title, author:book.author,publishedYear:book.publishedYear,genre:book.genre , pageCount: book.pageCount} +const newbook : Book = book; +newbook.pageCount = pageCount; + return newbook; } /** @@ -88,7 +90,8 @@ function addPageCount(book: Book, pageCount: number): Book { */ function addISBN(book: Book, ISBN: string): Book { // write your code here... - + const newbook : Book = book; + newbook.ISBN = ISBN; return book; } @@ -110,7 +113,8 @@ function addISBN(book: Book, ISBN: string): Book { */ function updatePublishedYear(book: Book, newYear: number): Book { // write your code here... - + const newbook : Book = book; + newbook.publishedYear = newYear; return book; } @@ -135,6 +139,9 @@ function updatePublishedYear(book: Book, newYear: number): Book { */ function addSecondAuthor(book: Book, additionalAuthor: string): Book { // write your code here... + let authors :string[] = [book.author+""] + authors.push(additionalAuthor) + book.author = authors; return book; }