Error: split is not a function

I have a string that is a latitude and longitude pair separated by a comma. I’m trying to separate the 2 parts of the string into separate variables, but for whatever reason, the “split()” function won’t work in my code. Everywhere I’ve looked online says to use “split()” and my syntax seems correct, so it’s really boggling my mind.

var latlongpieces = latlong.split(",");

When I try to run the page, I get this error in firefox:

Error: latlong.split is not a function

Anybody know what could be going wrong?

Are you absolutely sure that ‘latlong’ is a string? What happens if you do this? -

alert(typeof latlong);

Oh, it looks like the API was returning an object, not a string.

Thanks for the tip, I just got it working:

var latlongpieces = latlong.toString().split(",");
var latitude = latlongpieces[0];
var longitude = latlongpieces[1];