Note that there are some explanatory texts on larger screens.

plurals
  1. POMerge two intersecting arrays into a HashMap, One Key & Multiples values
    primarykey
    data
    text
    <p>I'm trying to make a basic calendar to help automate Timesheets at work using Angular.js and Chrome Extensions, but for now I am stuck on this part. </p> <p>Below you can see two arrays: <code>pastTwoWeeks</code> which is a list of dates from today back 14 days and Timesheet <code>entries</code> which were retrieved from an API - these will actually be objects with many properties but for now I am just using a simple date.</p> <p>Here's a jsfiddle, am I on the right track? Thanks <a href="http://jsfiddle.net/v599n/" rel="nofollow">http://jsfiddle.net/v599n/</a></p> <pre><code>var pastTwoWeeks = ['15/10/2013', '14/10/2013', '13/10/2013', '12/10/2013', '11/10/2013', '10/10/2013', '09/10/2013', '08/10/2013', '07/10/2013', '06/10/2013', '05/10/2013', '04/10/2013', '03/10/2013', '02/10/2013']; var entries = ['11/10/2013', '11/10/2013', '11/10/2013', '11/10/2013', '10/10/2013', '10/10/2013', '10/10/2013', '09/10/2013', '09/10/2013', '09/10/2013', '08/10/2013', '08/10/2013', '07/10/2013', '07/10/2013', '04/10/2013', '04/10/2013', '03/10/2013', '03/10/2013', '02/10/2013', '02/10/2013', '02/10/2013', '02/10/2013', '01/10/2013', '01/10/2013', '01/10/2013']; var calander = {}; for(var j=0; j&lt; pastTwoWeeks.length; j++) { var key = pastTwoWeeks[j]; if (key in calander == false) { calander[key] = {}; } for(var i = 0; i&lt; entries.length; i++) { var entry = entries[i]; if(entry === key){ calander[key][entry]; console.log(key + " " + entry); } } } </code></pre> <p>What I want to achieve:</p> <ul> <li>15/10/2013 </li> <li>14/10/2013 </li> <li>13/10/2013 </li> <li>12/10/2013 </li> <li>11/10/2013 (4 entries) <ul> <li>11/10/2013</li> <li>11/10/2013</li> <li>11/10/2013</li> <li>11/10/2013</li> </ul></li> </ul> <p>etc...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload