+ 2
Is there a way to format strings in java script?
java script built in functions
3 Answers
+ 7
decimal places - toFixed(n)
formatting - toLocaleString(<locale>)
example:
var x = 10000000
alert(x.toLocaleString('en-US'))
// outputs 10,000,000
more about locales:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
+ 5
mind giving an example?
format how exactly?
+ 2
formatting how many decimal places are shown or putting commas in large numbers such as 1,000,000.00