Calculer somme valeur tableau javascript
Résolu
Bonjour à tous, je souhaite faire la somme des valeurs chiffrées d'un tableau javascript, j'ai un problème au niveau de la variable "total".
Pourriez vous m'aider s'il vous plait ?
Voici le code :
var prestation = [
["banniere", 100, 0],
["affiche", 40,30 ],
["illustration", 50, 0],
];
for (var i = 0; i < prestation.length; i++) {
var mont_presta = new Array();
mont_presta[i]= prestation[i][1] + prestation[i][2] +"<br>"
document.write( mont_presta[i] +"<br>" );
}
for(var j = 0 ; j < mont_presta.lenght; j++){
var total = 0;
total += (mont_presta[j]);}
document.write( total );
Pourriez vous m'aider s'il vous plait ?
Voici le code :
var prestation = [
["banniere", 100, 0],
["affiche", 40,30 ],
["illustration", 50, 0],
];
for (var i = 0; i < prestation.length; i++) {
var mont_presta = new Array();
mont_presta[i]= prestation[i][1] + prestation[i][2] +"<br>"
document.write( mont_presta[i] +"<br>" );
}
for(var j = 0 ; j < mont_presta.lenght; j++){
var total = 0;
total += (mont_presta[j]);}
document.write( total );