Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function addReview(
comment: string
): ReviewedBook {
// write your code here...

book.reviews
? book.reviews.push({ reviewer: reviewer, comment: comment })
: (book.reviews = [{ reviewer: reviewer, comment: comment }]);
return book;
}

Expand Down
19 changes: 13 additions & 6 deletions src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ function createBook(
): Book {
// write your code here...

return {} as Book; // replace "{} as Book" with what you see is fit
return {
title: title,
author: author,
publishedYear: publishedYear,
genre: genre,
} as Book; // 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)
Expand All @@ -51,7 +56,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
}

/**
Expand All @@ -66,7 +71,7 @@ function printBookTitleAndYear(book: Book): string {
*/
function addPageCount(book: Book, pageCount: number): Book {
// write your code here...

book.pageCount = pageCount;
return book;
}

Expand All @@ -88,7 +93,7 @@ function addPageCount(book: Book, pageCount: number): Book {
*/
function addISBN(book: Book, ISBN: string): Book {
// write your code here...

book.ISBN = ISBN;
return book;
}

Expand All @@ -110,7 +115,7 @@ function addISBN(book: Book, ISBN: string): Book {
*/
function updatePublishedYear(book: Book, newYear: number): Book {
// write your code here...

book.publishedYear = newYear;
return book;
}

Expand All @@ -135,7 +140,9 @@ function updatePublishedYear(book: Book, newYear: number): Book {
*/
function addSecondAuthor(book: Book, additionalAuthor: string): Book {
// write your code here...

Array.isArray(book.author)
? book.author.push(additionalAuthor)
: (book.author = [book.author, additionalAuthor]);
return book;
}

Expand Down