api - Rounding to decimal point in jQuery -
i pulling 2 objects json response bing maps api
, how can trim loc[0] , loc[1] 4 decimal places using jquery
?
var loc = result.resourcesets[0].resources[0].point.coordinates; $("#resultscoords").html(loc[0] + ',' + loc[1]);
the tofixed function round number digits specify, whether there more or less.
example
n = 1.0; n.tofixed(2); // returns 1.00 y = 1.1432176452; y.tofixed(2); // returns 1.14
in case, applied following way:
var loc = result.resourcesets[0].resources[0].point.coordinates; $("#resultscoords").html(loc[0].tofixed(4) + ',' + loc[1].tofixed(4));
this return 2 results, rounded 4 decimal places.
Comments
Post a Comment