how do i concatenate input values and convert them to an overall number?
<p>I have 4 buttons with values 1 - 4, I want to concatenate the button value each time a number is clicked and present this in <code>#result</code> but I'm getting confused by how this should be done. At the moment I have created an array and then pushed each value into the array as it is clicked then going onto convert this to a string which I will then convert to a number but I'm guessing this is the totally wrong approach, can anyone advise how I can achieve this?</p>

<p>JavaScript</p>

<pre><code>$(document).ready(function () {

  var arr = [], value;

  $('.num').on('click', function(e) {
    value = $(this).val();
    arr.push(value);
    var test = parseInt(arr.toString());
    console.log(test);
    $('#result').text(test);


  });

});
</code></pre>

<p>HTML</p>

<pre><code> &lt;form id="myForm"&gt;
    &lt;input type="text" id="result" /&gt;
    &lt;input type="button" class="num" value="1" /&gt;
    &lt;input type="button" class="num" value="2" /&gt;
    &lt;input type="button" class="num" value="3" /&gt;
    &lt;input type="button" class="num" value="4" /&gt;
  &lt;/form&gt;
</code></pre>

<p>JSBIN  - <a href="http://jsbin.com/exuwuz/2/edit" rel="nofollow">http://jsbin.com/exuwuz/2/edit</a></p>

<p>So basically hit 1 and #result will show 1 hit 2 and #result will show 12 etc etc?</p>
