I want to add the data of some data-attributes within a simple formula. But the values don't get interpreted as numbers, but as strings. I do it like that:
var nutzer = document.getElementById('chosen_meals').getElementsByTagName('p');
var kalorien = 0;
for (var i = 0; i < amountOfMeals_low; i++) {
var kalorien = kalorien + nutzer[i].dataset.kal;
console.log(kalorien);
}
And the markup is some like that
<ul id="chosen_meals">
<li>
<p data-kal="420">Foo</p>
</li>
<li>
<p data-kal="180">Foo</p>
</li>
</ul>
And I do get logged 0 0420 0420180
How would I get it to be the result of 600?