title: Javascript - Trying count a sum from 1 to the number that user entered
body: <p>I am very new to javascript, and have limited knowledge. I have just grasped the concept of hello world. At the moment, my code adds FirstNumber and SecondNumber together to give the result. I would like it to do the following: </p>
  
  <p>I am trying to make a program where FirstNumber is pre-defined as 1 and SecondNumber is done by user input. The javascript should count a sum from 1 to the number that should be entered. For example, if the user entered 5, the program  should count the sum from 1 to 5 (1 + 2 + 3 + 4 + 5) which will be 15. I was told to maybe use an array, although I'm not sure.</p>
  
  <p>Here is my HTML code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Sum of numbers&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function sum()
  {
      var FirstNumber = 1;
      var SecondNumber = document.getElementById('txtSecondNumber').value;
      alert(parseInt(FirstNumber) + parseInt(SecondNumber));
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Please enter a number:&lt;input id="txtSecondNumber" type="text" /&gt;
  &lt;input id="btnAdd" type="button" value="Add" onclick="sum();"/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Could someone help?</p>
  
  <p>Thanks :)</p>