title: calculating average using for loop in javascript
body: <pre><code>function averageCalculator (numvalues) {
  
      for(i=0, i &lt;= numvalues, i++&gt;) {
      var score = prompt("input the score")
      result1 += score;
  
      }
  
      alert(result1 / 3);
  }
  </code></pre>
  
  <p>this function is later triggered by a button with <code>onclick="averageCalculator (2)</code></p>
  
  <pre><code>&lt;input type="button" value="Click for the average" onclick="averageCalculator (2)"&gt;
  </code></pre>
  
  <p>any ideas why its not working? it should prompt you for 2 values and then alert you with the average. not sure whats wrong.</p>