Here is a piece of an application that parses JSON input and displays books data with reviews.
Your job is to implement two functions at src/app/app.js
file. Build the project to run the unit tests and check how your code works with sample data.
-
Implement
parseBooksData(books, reviews)
that will create an array ofBookWithReview
objects, by parsing passed arraysbooks
andreviews
. You can find a sample data atapp/dataset/books.json
file and atapp/dataset/reviews.json
file. Data fromapp/dataset/books.json
will be passed asbooks
argument and data fromapp/dataset/reviews.json
will be passed asreviews
argument. EachBookWithReview
object should contain theid
,title
and all reviews matched bybookId
attribute fromreviews
array. -
Implement
displayBooks(parentNode, books)
that should append DOM nodes to passedparentNode
to render information about passedbooks
array which containsBookWithReviews
objects. For sample data located atapp/dataset
following DOM tree should be created under theparentNode
:
<ol>
<li>
<span>Some book title</span>
<ul>
<li>Great book! by John</li>
<li>Worth reading. by Alice</li>
</ul>
</li>
<li>
<span>Another book title</span>
<ul>
<li>Waste of time :( by Joe</li>
</ul>
</li>
<li>
<span>Best book title ever</span>
</li>
</ol>
Build the project at any time to check if your code is passing tests.
Good luck!