Generate array of times (as strings) for every X minutes in JavaScript
<p>I'm trying to create an array of times (strings, not <code>Date</code> objects) for every X minutes throughout a full 24 hours. For example, for a 5 minute interval the array would be:</p>

<pre><code>['12:00 AM', '12:05 AM', '12:10 AM', '12:15 AM', ..., '11:55 PM']
</code></pre>

<p>My quick and dirty solution was to use 3 nested <code>for</code> loops:</p>

<pre><code>var times = []
  , periods = ['AM', 'PM']
  , hours = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
  , prop = null
  , hour = null
  , min = null; 

for (prop in periods) {
  for (hour in hours) {
    for (min = 0; min &lt; 60; min += 5) {
      times.push(('0' + hours[hour]).slice(-2) + ':' + ('0' + min).slice(-2) + " " + periods[prop]);
    }
  }
}
</code></pre>

<p>This outputs the desired result but I'm wondering if there's a more elegant solution. Is there a way to do this that's:</p>

<ul>
<li>more readable</li>
<li>less time complex</li>
</ul>