Get the Flavors: Solution Review
Solution review.
We'll cover the following...
We'll cover the following...
So a given employee’s JSON is shaped like this
And their flavor’s tucked away here
That’s quite a few levels to go through, so Ramda’s path function is a good start.
Our solution must use lenses, so this can easily become a lensPath and view combination.
But this only works for one person! Using it on a list of people returns undefined because your using view on the array.
How do we generalize a solution to a list?
Map
As we previously discussed, lenses use map themselves. When they receive the data, they begin unfolding and traverse the data structure.
Adding map on top of that just loops through employees and feeds each one to view as data.
Our result is an array of everyone’s favorite flavor!