javascriptsubstringcycript

How do I shorten returned coordinates?


Using Cycript (mixed with javascript) via a tweak I have this code:

var latitude = [IS2Weather currentLatitude];

This returns -1.65456038607131e+25

I want to limit it to 6 decimal places (-1.654560), what is the correct way to achieve this please? I can't seem to get anything to work.


Solution

  • Use javascript .toFixed(n) method

    latitude = latitude.toFixed(6);