Skip to content
Advertisement

Mapping arrays into object with values as an array

I would like to create an object containing all the values from the array first and the values from second as an array of values, assuming that this key references multiple numbers such that given the arrays:

JavaScript

This is what I have tried:

JavaScript

This is what I get:

JavaScript

Advertisement

Answer

This is the easiest method to understand as it’s just the bare logic written in its entirety.

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