If the details of a book are provided in the below format:
Key | Value |
---|
title | Malgudi Days |
author | R. K. Narayan |
"alreadyRead" | true |
isAvailable | true |
Write code that takes in these book details to perform the following actions:
-
For each book, use the format, [Book Name] by [Author Name]
and print the book title and book author.
-
You need to print these additional statements to the console based on the provided conditions:
-
If the user has read the book: You have already read [Book Name] by [Author Name].
-
If the user has not yet read the book and it is available.": Since [Book Name] by [Author Name] is available, you can read it next.
-
If the user has not yet read the book, but it is not available: Currently, $[Book Name] by [Author Name] is unavailable. You can plan to read it next once it becomes available.
Make sure your code is flexible enough to work with any value of the bookDetails
variable that meets these requirements.