Modify array of arrays to create custom array of objects I have an array of arrays and I want to create an array of objects from it. There are custom properties to which I want to associate the sub-array values. I have the following array:

var testArray = [[1,5,10], [10,20,7], [11,10,25]];


I am modifying it to create the following

[{
    coordinates: [1, 5],
    reach: 10,
    power: 0
},
{
    coordinates: [10, 20],
    reach: 7,
    power: 0
},
{
    coordinates: [11, 10],
    reach: 25,
    power: 0
}]


For this I have written the following code. 

function modifyArray(array) {
    return array.map(array =&gt; {
        return Object.assign({}, { coordinates: array.slice(0, 2), reach: array[2], power: 0 });
    });
}


I get the desired result. My question is if this is a good way to modify this type of data performance wise, since the function has two return statements. How can I improve on this code?
Overview


You're overwriting the name array in defining the mapping param.
You don't need to assign to a new object. This is done for you.


Rewrite

function modifyArray(arrays) {
    return arrays.map(array =&gt; {
        return { coordinates: array.slice(0, 2), reach: array[2], power: 0 };
    });
}