Good morning.
How can I make the sum of values obtained from JSON and interpreted with JS. In the following code I get my data brought with json and I go through it with the for to show them, among them the campo datos[dato].bultos
I need to add their obtained values.
for(var dato in datos) {
var temp = [datos[dato].referencia,datos[dato].estilo,datos[dato].bultos,datos[dato].piezas
_teoricas,datos[dato].total_piezas];
data.push(temp);
var totales = parseInt(datos[dato].bultos); //Aqui quiero los mis valores como el comentario var totales = [18,1,153,1,62,1];
// var totales = [18,1,153,1,62,1];
var valor = 0;
for( var i=0; i < totales.length;i++){
valor += totales[i];
}
console.log(valor);
}
In my var totales
I get my values showing it with console.log: var totales = parseInt(datos[dato].bultos);
in my for (var i=0; i < totales.length;i++)
I made the process to do the sum and I get the result is 0.