Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 207

how to find sum of input value in javascript

$
0
0

Can anyone help me to find sum of input values using JavaScript. The HTML and JavaScript is given below. Thanks in advance

let inputs=document.getElementsByTagName('input');let button=document.querySelector('button');button.addEventListener('click',function(){let sum='';for(let i=0;i<inputs.length;i++){sum+=parseInt(inputs[i].value);}console.log(sum);})
<input type="text"><input type="text"><button>Find Sum</button>

Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>