title: Convert String to Array in JavaScript -- difficulty formatting alert
body: <p>I want to convert string into array and put them. I try an event click of button #bt_click. It prints an alert. </p>
  
  <p>Example Code follows:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function ()
      {
  
          $("#bt_click").click(function (e)
          {
              e.preventDefault();
              alert(string_to_array('Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|'));
          });
  
          function string_to_array(string_text)
          {
              var res = new Array();
              res =   string_text.split("|");
              for (var i = 0; i &lt; res.length; i++)
              {
                 return res[i] +  '&amp;nbsp;&amp;nbsp;&lt;br /&gt;';
              }
          } 
  
           });
  </code></pre>
  
  <p></p>
  
  <p>Intended result of alert: </p>
  
  <pre><code>Jan  Feb  Mar  (line 1)
  Apr  May  Jun  (line 2)
  Jul  Aug  Sep   (line 3)
  Oct  Nov  Dec   (line 4)
  </code></pre>
  
  <p>How can I format alert correctly. Thanks all.</p>