title: Javascript - remove split method
body: <p>I am trying to create the select application using Javascipt only. I got to know about this code on internet and it uses the split method to return value and .innerHTML. Now say if I do not want to use the split method and just return with .innerHTML into html element with no value, how to do that using for loop as used in this code ?</p>
  
  <pre><code>   &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Select Options&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Choose your car&lt;/h2&gt;
  &lt;hr&gt;
  
  Choose Car Make:
  &lt;select id="slct1" onchange="populate(this.id,'slct2')"&gt;
      &lt;option value=""&gt;&lt;/option&gt;
      &lt;option value="Hyundai"&gt;Hyundai&lt;/option&gt;
      &lt;option value="Honda"&gt;Honda&lt;/option&gt;
      &lt;option value="Maruti"&gt;Maruti&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;hr&gt;
  
  Choose Car Model
  &lt;select id="slct2" &gt;&lt;/select&gt;
  
  &lt;/body&gt;
  
  &lt;script type="text/javascript"&gt;
      function populate(s1,s2){
          var s1 = document.getElementById(s1);
          var s2 = document.getElementById(s2);
          s2.innerHTML = "";
  
          if(s1.value == "Hyundai") {
              var optionArray = ["|", "i10|i10","i20|i20", "Verna|Verna"]
          }
          for(var option in optionArray){
              var pair = optionArray[option].split("|");
              var newOption = document.createElement('option');
              newOption.value = pair[0];
              newOption.innerHTML = pair[1];
              s2.options.add(newOption);
          }
      }
  &lt;/script&gt;
  
  &lt;/html&gt;
  </code></pre>