Console.log()

Diary of an aspiring software engineer

Member-only story

Nested reduce() in JS

--

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:

--

--

Abrar Shariar
Abrar Shariar

Responses (2)