Truncate array items to the first five characters with jQuery?
<p>A plugin I use on my site generates an array in this style:</p>

<pre><code>&lt;script type="text/javascript"&gt;
  window.slideDetails = [ 

    //Slide1    
    "C1BP7: user information",
    "FJAD7: user information",
    "FFAD7: user information",
    //Slide2
    "C0AE7: user information",
    "C7AZ7: user information",
    "FJAE7: user information",
    //Slide3
    "C1AW7: user information",
    "FJAP7: user information",
    "FFAD7: user information"

    ]; 
&lt;/script&gt;
</code></pre>

<p>I want to pass the first five characters to a cookie using the jQuery cookie plugin. Is it possible to truncate the array item to the first five characters?</p>

<p>I'm trying to get my head around the slice() but the different codes I've tried don't work at all. </p>

<p>EDIT:</p>

<p>With thanks to andreas for his answer, I adapted it slightly to this:</p>

<pre><code>window.slideCode = [], i;

  for(var i = 0; i &lt; window.slideDetails.length; i++) { 
    window.slideCode.push(window.slideDetails[i].substr(0, 5));
}
</code></pre>
