Hi I have a string of numbers separated by commas "100,200,300,400,500" which I split into an array using the javascript split function:
var data = [];
data = dataString.split(",");
I am trying to parse the values โโof an array using parseFloat and then save them back to the array. Then I would like to add numbers to the array and save it as another "dataSum" variable.
I have the following code, but I cannot get it to work:
var dataSum = "";
for (var i=0; i < data.length; i++) {
parseFloat(data[i]);
dataSum += data[i];
}
So, at the end of all this, I should be able to access any of the parsed numbers separately for data [0], data [1], etc ... and have a total number for dataSum. What am I doing wrong?
source
share