I have been struggling to find a solution to a seemingly simple problem. Despite searching through various sites and resources, I have not been able to figure out how to iterate over the innermost levels of a doubly nested data structure. I have tried using methods like forEach() and map() without any success.
Here is some background information on the data I am working with. The data provided below is extracted from an array that contains information about two retail stores. Each store object includes a property called visits
, which stores an array of visit objects. Each visit object is uniquely identified by a visit date and includes a values
property that holds an array of transactions, such as purchases or returns, made during that visit. In the complete dataset, the number of transactions can vary significantly from one date to another.
The specific tasks I need assistance with are as follows:
(a) Change the property key
to visitDate
,
(b) Rename the property values
to transactions
,
(c) Remove 8 unnecessary properties (from storeID
to storeVisitDate
), while keeping the action
and dollarAmount
properties, and
(d) Update the property dollarAmount
to dollars
.
I would greatly appreciate any help that can be provided. Thank you.
[ ... ]