2 votes

Separating Arrays into JavaScript Objects

I have the following problem. I have this array:

But that array I need to convert it into an array of objects, like this:

I can't really think of anything to do:(

4voto

F.Igor Points 286

The easiest way to convert an array to a different formatted array is to use ``

<div class="snippet" data-babel="false" data-console="true" data-hide="false" data-lang="js"> <div class="snippet-code">

</div></div>

0voto

me rapa Points 1

The solution by F.log is fine, but change the variables declared with var to const or let to correctly control the scope of the variables.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X