Skip to content
Advertisement

How to reduce an array of object for unique key value pairs using an another array?

I have an array of object that contains different key value pairs and I’m trying to reduce this array of object using an another array.

I can refer the array that need to be reduced as the “Reducible Array” and the array I’m using to reduce as “Key array”.

Reducible Array:

JavaScript

Key Array:

JavaScript

The reduced array of object I’m expecting after the operation is as follows.

Expected Result:

JavaScript

What are all the operations I need to perform to get the expected result?

Advertisement

Answer

Since you naturally felt to use the word reduce you must know that javascript offers such a method to reduce arrays:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement