So I have this code, where I what with a button increase amount and by increasing amount the weight changes with it.
The result of the code below, by clicking the button innerText changes to
for example
1piece = 8 g
2piece = 16 g
3piece = 48 g -> here is the problem - I want the number increase by the first value (38 = 24), but its doing (316)
How can I fix this? The weight is not a variable set on 8, but has for every element a different value, thats why its called in const. Element are from JSON file in an array map
let amount = document.getElementById('amount');
let weight = document.getElementById('weight');
function add(el, pt) {
{
amount = parseInt(document.getElementById(el).innerText);
weight= parseInt(document.getElementById(pt).innerText);
amount++
let totalPt = weight * amount
document.getElementById(el).innerText = amount;
document.getElementById(pt).innerText = totalPt;
}
}```