So i’m trying to do something pretty simple.
I have an array that looks like this
l = [0.5, 4.5, 7.5]
I want to convert it to the following array of objects
obj = [
{value: 0.5, width:2},
{value: 4.5, width:2},
{value: 7.5, width:2}
]
I seem to keep tripping up on this. Any help would be much appreciated. thanks
>Solution :
Something like this?
const numbers = [ 0.5, 4.5, 7.5 ];
const objects = numbers.map( n => ({ value: n, width: 2 });