JavaScript: cycle through an array (rather than pop)?
<p>I'm creating map markers, and I want to assign a different colour to each county on the map. </p>

<p>I don't know in advance how many counties there will be showing on the map, so I need to figure out a way to assign an unlimited number of colours. </p>

<p>At the moment, I'm assigning a colour to each county using the following code, but I run into a problem when I <code>pop()</code> the list too many times:</p>

<pre><code>var colours = ['6183A6', '3A66A7', '3B4990', '5B59BA'];
var h_colours = []; // associative array 
function addMarker(county, colour) {
if (colour==undefined) {
    if (h_colours[hundred]==undefined) {
            h_colours[hundred] = colours.pop();
    } } }
</code></pre>

<p>Is there a way I could cycle through the list without actually deleting items, and continuing from the start of the list when I reach the end?</p>

<p>thanks!</p>
