# Nested reduce() in JS

Published in

1 min readJun 24, 2020

Sample data structure:

Now, we want to find the total prices, for which we would need to add all the prices in the two records which are essentially part of two objects in the `purchases`

array.

The following code solves it: