What is the best way of converting an array of arrays to objects so that the indices are replaced with given mapping properties.
For example:
let cars = [
[1, "Honda", "Honda description here"],
[2, "Mercedes", "Mercedes description here"],
[3, "Toyota", "Toyota description here"],
];
let mapping = {
0: 'id',
1: 'name',
2: 'description',
};
So the final result is:
[
{id: 1, name: 'Honda', description: 'Honda description here'},
{id: 2, name: 'Mercedes', description: 'Mercedes description here'},
{id: 3, name: 'Toyota', description: 'Toyota description here'},
];
.map()function for the outer loop.map()function of arrays.