Converting numbers returned from API_DoQuery from string to number

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered

I have an API_DoQuery which returns data in XML which I then process in Jquery and assign to a two-dimensional array.

I want to add some of this data but for some reason I get NaN when trying to convert the data to numbers using parseFloat() even though they are "strings" and appear to be number formatted... Any ideas why??? ...

///// Code Snippet:

console.log(currdata);

console.log(typeof currdata);

AVMI_QL_TF[m] += parseFloat(currdata);

console.log (AVMI_QL_TF[m]);

///// Browser Console Log:

1

string

NaN

1289.99

string

NaN

1

string

NaN

13712.25

string

NaN

1

string

NaN

6439.20

string

NaN

Photo of David

David

  • 20 Points

Posted 2 years ago

  • 0
  • 1
Photo of David

David

  • 20 Points
It turns out that my array needed to be populated with zeros before I started adding the values to it... bit annoying but got around it.