-2

I have the following array and three vars:

array1 = ['']

    dateOutput = 1/1/14
    timeOutput = 12am
    tallysave = 100

I was using this to push in the three vars on a push

array1.push(dateOutput + ', ' + timeOutput + tallysave)

However how can I push each of the vars into the array so they will be like this when pushed: (multi-dimensional array?)

array = [
        { "date": dateOutput, "time": timeOutput, },
    ];   
craig
  • 571
  • 2
  • 4
  • 13
  • That is not a multidimensional array. It is an array with an object as its only value. It would be something like `array1.push({ "date": dateOutput, "time": timeOutput })` – putvande Jan 23 '14 at 09:20
  • http://stackoverflow.com/questions/7813374/javascript-array-push-key-value – Rahul Desai Jan 23 '14 at 09:21

2 Answers2

0

You can push the data as an object:

array1.push({
   "date": dateOutput, 
   "time": timeOutput 
});   
Matyas
  • 13,473
  • 3
  • 60
  • 73
0
array1.push({ "date": dateOutput, "time": timeOutput})

or

array1.push([dateOutput, timeOutput])

But in the second way you should know that dateOutput with index 0, and timeOutput with index 1

Alex Kapustin
  • 1,869
  • 12
  • 15