-1
Would you be so kind as to help me?
I’m trying to make a function that adds up several inputs, but instead of adding it is concatenating.
HMTL
<form class="nacional">
<input class="soma-nacional" value="5">
<input class="soma-nacional" value="3">
<input class="soma-nacional" value="2">
</form>
JS
var nacional = document.querySelectorAll(".soma-nacional");
var somaNacional = [];
function somatoriaNacional(){
var soma = [];
for(var i = 0; i < nacional.length; i++){
soma += parseInt(nacional[i].value);
}
console.log(soma);
}
Edit the original question so that it can be reopened...
– Luiz Felipe