function Sum(ysums) {
for (var ys in ysums) {
var ysz = ysums[ys];
$('.y-sums h1 span').each(function () {
$(this).text(ysz);
});
}
}
<div class="y-sums">
<h1>sum1 – <span>0</span></h1>
<h1>sum2 – <span>0</span></h1>
<h1>sum3 – <span>0</span></h1>
</div>
var ysums=[123,456,789];
function Sum(ysums) {
for(var i=0;i<ysums.length;i++){
$('.y_sums h1 span').eq(i).text(ysums[i]);
}
}
Sum(ysums);