title: Using a for loop and document.getElementById to populate an array in Javascript
body: <p>I have been trying to populate an array using a for loop and taking such values using <code>document.getElementById("spin " + i).value;</code></p>
  
  <p>The <code>ids</code> on my html for every input tag go from spin1 to spin18.</p>
  
  <p>Any suggestions on what I am doing wrong? Or what I can change?</p>
  
  <pre><code>var nums = [];
  
  for(var i = 1; i &lt;= 18; i++){
      var num[i] = parseInt(document.getElementById("spin" + i).value);
  
      nums.push(num[i]);
  
  }
  
  alert(nums.length);
  </code></pre>