0

How covert or add array elements into object.

Now

arr = [
  ["1/1/2017",113],
  ["3/11/2017",58],
  ["3/12/2017",70],
  ["3/13/2017",76]
]

Should be

arr = [
  {date:"1/1/2017", count:113},
  {date:"3/11/2017", count:58},
  {date:"3/12/2017", count:70},
  {date:"3/13/2017", count:76}
]
Arun Kumar M
  • 1,633
  • 1
  • 15
  • 26

1 Answers1

3
arr.map(function(arr1) {
 return {
  date : arr1[0],
  count : arr1[1]
 }
})
Sanchay Kumar
  • 566
  • 5
  • 11