Reputation: 39
AS3:
public static function testFunction(a:Number, b:String="", c:String=""):String {
var fmt:NumberFormatter = new NumberFormatter();
fmt.precision = -1;
fmt.useThousandsSeparator = false;
var s:String = fmt.format(a);
}
How to convert it to Javascript. I'm very confused and I think I need NumberFormatter in JS. Any recommend suggestions?
Upvotes: 0
Views: 60
Reputation: 109
You can set precision like this
var num = 13.3714;
var n = num.toPrecision(2);
for more info see http://www.w3schools.com/jsref/jsref_toprecision.asp
also http://openexchangerates.github.io/accounting.js/ and
http://numeraljs.com/
Upvotes: 2