title: Jquery using map to sum array
body: <p>My values array is returning correctly in the form of [100,200,300,500] I just wish to sum up these values, what am I doing wrong?</p>
  <h2>Jquery</h2>
  <pre><code>$('select').focus(function () {
      previous = parseInt($(this).val());
  }).change(function() {
  
      var item_cost = parseInt($(this).attr('cost'));
      
      values = $.map($('select[name=&quot;cookies&quot;]'), function (e) {
              
          return $(e).val()* item_cost;
                       
          for (var i = 0; i &lt; values.length; i++) {
              total += parseInt(values[i]);
              console.log(total);                              
          }
      });
  
      alert(values);
  </code></pre>