title: Get all span innerHTML in an array
body: <p>So I m trying to understand JS, been doing a little JS project to learn it. Trying to make a simple calculator with javascript/html but got stuck already. </p>
  
  <p>I want to get the innerHTML from all the spans in an array, but I can't figure out how to do it. (I want to use pure JavaScript). What I tried is this:</p>
  
  <pre><code>var allSpans = document.getElementsByTagName('span');
  var arrayNumbers = [];
  
  for (var i = 0; i &lt;= allSpans.length; i++) {
     arrayNumbers.push(allSpans[i].innerHTML);
  }
  </code></pre>
  
  <p>And my html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset=utf-8 /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="calculator"&gt;
      &lt;span class="numb"&gt;1&lt;/span&gt;
      &lt;span class="numb"&gt;2&lt;/span&gt;
      &lt;span class="numb"&gt;3&lt;/span&gt;
      &lt;span class="calc"&gt;x&lt;/span&gt;&lt;br /&gt;
  
      &lt;span class="numb"&gt;4&lt;/span&gt;
      &lt;span class="numb"&gt;5&lt;/span&gt;
      &lt;span class="numb"&gt;6&lt;/span&gt;
      &lt;span class="calc"&gt;/&lt;/span&gt;&lt;br /&gt;
  
      &lt;span class="numb"&gt;7&lt;/span&gt;
      &lt;span class="numb"&gt;8&lt;/span&gt;
      &lt;span class="numb"&gt;9&lt;/span&gt;
      &lt;span class="calc"&gt;√&lt;/span&gt;&lt;br /&gt;
  
      &lt;span class="numb"&gt;0&lt;/span&gt;
      &lt;span class="calc"&gt;+&lt;/span&gt;
      &lt;span class="calc"&gt;-&lt;/span&gt;
      &lt;span class="calc"&gt;=&lt;/span&gt;&lt;br /&gt;
      &lt;input type="text" &gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What is the best methode to use and why? Trying to learn it the proper way :) Many thanks!</p>