How to fold a group of numbers using jQuery?

There is a div with nested span like this:

<div id="calc-table">
<span>1</span>
<span>7</span>
<span>2</span>
....
</div>


span's can be any number, of 2 or more.

Question: how can I add the numbers inside these span? Ie in this case the output should be the number 10.
July 9th 19 at 13:01
2 answers
July 9th 19 at 13:03
Solution
var summ = 0;
$('#calc-table span').each(function() {
 summ += $(this).text() * 1;
});

console.log(summ); // 10
Thanks, trying to learn javascript, I decided to sit down for a simple calculator, but something already don't think it was worth it to start :) - viviane_Gra commented on July 9th 19 at 13:06
July 9th 19 at 13:05
Solution
console.log(
 $('#calc-table span').toArray().reduce((summ, current) => +current.innerText + summ, 0);
)
Thank you - viviane_Gra commented on July 9th 19 at 13:08

Find more questions by tags HTMLJavaScriptjQuery