I want to push numbers into the array and sum them and display the result, but my code doesn't work. What is the problem?

I want to push numbers into the arrays (It works) and sum and display them, but this doesnt work. What is the problem with my code? How can i handle it?

let y = document.getElementById('addNumbers');
y.addEventListener('click', pushAdd)
let sum = 0;


let addition = [];

function pushAdd() {
    let c = Number(document.getElementById('numbers').value);
    addition.push(c);
    document.getElementById('numbers').value = "";    
}
    addition.forEach(summa);
    function summa(item) {
    sum += item;  }
    

    
document.getElementById('display').innerHTML = sum;


from Recent Questions - Stack Overflow https://ift.tt/3w1WPMs
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations