![]() Let's write the reducer function separately, which will be passed to the reduce() method. We often need it awards the traversal through an array and perform a fast look up on the data. ![]() It should be an object containing keys, which are property ids and their value is the property object itself.Ġ0:45 This is pretty common operation. Our goal is to convert this array into an object such that look up happens through the property id. Each object contains id, name and price for a property. Let's say we have an array called realEstate containing multiple objects. The link is in the description below, so I recommend you watch that first and then work on the code for this problem. If you would like to do a quick refresh on what reduce method is and how it works, I covered that in the previous video. In this video, we will learn how to convert a given array into a JavaScript object using reduce higher order function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |