Hi I am trying to sum an array on Javascript with the following codes.
var data[]: var total=0; data.push[x]; // x is numbers which are produced dynamically. f
Simply whip a unary + before data[i] to convert the string values to numeric values:
data[i]
total = total + (+data[i]);
Even better, use += instead of total=total+...:
+=
total=total+...
total += +data[i];
JSFiddle demo.