Javascript array of objects specific format

64 Views Asked by At

I got an array of objects and I want to display it like:

data: [
    { year: '2008', value: 20 },
    { year: '2009', value: 10 },
    { year: '2010', value: 5 },
    { year: '2011', value: 5 },
    { year: '2012', value: 20 }
],

I need this to use it for morris.js, but I can't do it manually like object[0] because I dont know the total length of the array.

Is there any way to get these format from this one?

Array [ Object ]
1

There are 1 best solutions below

0
On

set your array as the data objct i.e. data:yourarray