diff --git a/src/objects.ts b/src/objects.ts index ef6298f..2a671f2 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -27,6 +27,7 @@ function createBook( genre: string ): Book { // write your code here... + return {title, author, publishedYear, genre} return {} as Book; // replace "{} as Book" with what you see is fit } @@ -50,6 +51,7 @@ const book = createBook( */ function printBookTitleAndYear(book: Book): string { // write your code here... + return book.title + " " + book["publishedYear"] return ""; // replace empty string with what you see is fit } @@ -66,6 +68,7 @@ function printBookTitleAndYear(book: Book): string { */ function addPageCount(book: Book, pageCount: number): Book { // write your code here... + book.pageCount = pageCount return book; } @@ -88,6 +91,7 @@ function addPageCount(book: Book, pageCount: number): Book { */ function addISBN(book: Book, ISBN: string): Book { // write your code here... + book.ISBN = ISBN return book; } @@ -110,6 +114,7 @@ function addISBN(book: Book, ISBN: string): Book { */ function updatePublishedYear(book: Book, newYear: number): Book { // write your code here... + book.publishedYear = newYear return book; } @@ -135,6 +140,13 @@ function updatePublishedYear(book: Book, newYear: number): Book { */ function addSecondAuthor(book: Book, additionalAuthor: string): Book { // write your code here... + if (Array.isArray (book.author)){ + book.author.push(additionalAuthor) + } + else { + book.author = [book.author, additionalAuthor] + } + return book; }