Skip to content
Advertisement

Create new Array using two Arrays Specific data and values

I want to create a new Array using two arrays.

JavaScript

There is a itemTypeId i want to get itemTypeName match with itemTypeId.

JavaScript

Expected Array

JavaScript

I added below tried solution but its contain unwanted key-value pairs also.

JavaScript

Attached screenshot of output.

enter image description here

Advertisement

Answer

You can create a Map object and map it with time complexity O(1):

JavaScript

An example:

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