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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -