get decimal for javascript

if you have a string and want convert to decimal, you can use this :
var dian = “12.05″;
var purnomo = (parseFloat(dian)).toFixed(2);

and the result is => 12.05

NB : parseFloat is convert from string to float value
and toFixed(2) is the precision for your decimal value.

this is a simple way….i thik’s… :)

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.