title: what is the way to reuse same code multiple times in jquery html
body: <p>like below code i have to do 90 calculations how can i do this calculations with less code</p>
  <pre><code>$(document).ready(function () { 
  $(&quot;#btn&quot;).click(function () {
  var v1 = parseInt($(&quot;#1val&quot;).val());
  var v2 = parseInt($(&quot;#2val&quot;).val());
  var sum = v1 + v2;
  $(&quot;#result&quot;).text(sum);
  console.log(sum);
  
  var v1 = parseInt($(&quot;#1val2&quot;).val());
  var v2 = parseInt($(&quot;#2val2&quot;).val());
  var sum1 = v1 + v2;
  $(&quot;#result1&quot;).text(sum);
  console.log(sum1);
  
  var v1 = parseInt($(&quot;#1val3&quot;).val());
  var v2 = parseInt($(&quot;#2val3&quot;).val());
  var sum2 = v1 + v2;
  $(&quot;#result2&quot;).text(sum);
  console.log(sum2);
  });
  });
  </code></pre>
  <p><a href="https://i.stack.imgur.com/kvm7E.png" rel="nofollow noreferrer">enter image description here</a></p>