I am making a script that allows me to perform operations to generate the total cost of the products:
var subtotal = 0;
var ivaValor = 0;
var total = 0;
selected.forEach(function(dato) {
var pretotal = dato.price * dato.quantity;
parseFloat(pretotal)
var total = total + pretotal;
});
console.log(total);
But total returns it to me as Not a number (NaN), at the moment I do not understand what happens since total is declaring int.
Note: I'm starting in JS:)