title: Pushing elements from JSON to a nested array [i][push here]
body: <p>I have 2 files: index.js, and list.json</p>
  
  <p>I want to take an element from list.json and add it into the nested array using the following structure: [hour][visits per hour]</p>
  
  <p>hour points to the index of the hour, so for ex: hour 12 is actually index 12. The problem is I keep getting undefined tags in the console. I will post it at the bottom to show you what I mean.</p>
  
  <p>Here is an excerpt from the json file, there are 28 lines in total:</p>
  
  <pre><code>[
    { "time":"01:34:19", "visits": 37 },
    { "time":"02:03:21", "visits": 42 },
    { "time":"02:22:35", "visits": 51 },
    { "time":"02:43:54", "visits": 31 },
    { "time":"03:31:43", "visits": 24 },
    { "time":"03:38:01", "visits": 27 },
    { "time":"05:29:57", "visits": 36 },
    { "time":"05:54:08", "visits": 47 },
    { "time":"06:11:17", "visits": 49 },
    { "time":"07:22:03", "visits": 51 },
    { "time":"07:27:09", "visits": 55 },
  ]
  </code></pre>
  
  <p>Here is Javascript attempt:</p>
  
  <pre><code>let json = require('./list.json');
  
  let visitsPerHr = [];
  visitsPerHr.length = 24;
  
  //I had to do this to avoid a type error in the 2nd loop
  for (let x = 0; x &lt; 24; x++) {
      visitsPerHr[x] = x;
  }
  
  let hour = -1;
  let visitCount = -1;
  
  for(let i = 0; i &lt; json.length; i++){
  
      //get hour &amp; parse
      hour = json[i].time[0] + json[i].time[1];
      hour = parseInt(hour, 10);
  
      //get visits and parse
      visitCount = json[i].visits;
      visitCount = parseInt(visitCount, 10);
  
      //push to the hour(index) the number of visits, later i need to reorder 
      //the visits based on highest amount if multiple ones exist within that hour.
  
      visitsPerHr[hour].push = visitCount;
  
  }
  </code></pre>
  
  <p>I need help pushing the visitCount to the relevant hour (index.) So upon looping each index(hours start from 1 to 23, I should be able to get all the visits for that index.</p>
  
  <p>An example of the result i am seeking for hour 7: [7][27,29,22] </p>
  
  <p>here is my current result:</p>
  
  <pre><code>2
  undefined
  2
  undefined
  2
  undefined
  2
  undefined
  5
  undefined
  6
  undefined
  6
  undefined
  6
  undefined
  6
  undefined
  7
  undefined
  7
  undefined
  7
  undefined
  7
  undefined
  7
  undefined
  8
  undefined
  9
  undefined
  10
  </code></pre>
  
  <p>and so on it goes till 23</p>