I have a simple parse to get the sum of a collection of textareas. It works fine, but if there's no value placed in the field, then the calculation just doesn't run.
How can I make the default value 0 without having the contents actually have to be 0? Like, I don't want the fields to load up with a 0 already waiting in the box - I just want the formula to not worry about empty fields.
Here's the jQuery:
jQuery(document).ready(function(){
  jQuery(".button1").click(function(){
  var set1 = function() {
  var calc1 = 0;
  $('.calc1').each( function(index,item) {
    calc1 += parseInt(jQuery(item).val());
  });
  $('.result1').html(calc1);
}
set1();
  });
});
The codepen can be seen here if you'd like to get a better idea: https://codepen.io/JTBennett/pen/NENMdP
I appreciate any help with this! I know it's probably a stupid mistake, but I've tried a few different things and not gotten anywhere yet.
 
     
     
    