i am making a menu calculator that gives you the total of the products, but im stuck cause i don't know where to start, 
i was thinking to use if else statement and put multiple id's on every button and somehow calculate the total but i think is very inefficient so if someone have a better idea, it would be perfect
!! oh by the way !! im generating the buttons elements with create-element and appendchild .
here is my code
////////////////////HTML//////////////////////////
<body>
<div class="icons-container" id="container">
</div>
<div class="displayer">
<p>price</p>
<p>total</p>
</div>
</body>
</html>
/////////////////Javascript//////////////////////////
nombres = ['Kg','Taco','Dorado','1LtCSM','1/2CSM','Boing','Cafe','Refresco'];
precios = [440,30,24,50,25,20,20,25];
Total = [];
const element = document.querySelector('.icons-container');
for(i=0;i<=7;i++){
let div = document.createElement('div');
let h3 = document.createElement('h3');
div.classList.add('cuadro');
div.appendChild(h3);
h3.textContent = `${nombres[i]}`;
h3.classList.add('icon-text');
element.appendChild(div);
};
i haven't tried nothing but i was thinking to use if else and add different id's on every button to differentiate each one,
by using an array of objects, and a
.forEach()loop, we solve all your problems, in a simpler way.with this solution, there isn't any need to add
class=""orid=""to every button because we used a simple concept calledClosureshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures which makes.forEach()and.addEventListener()together work very fine here!