javascript - accounting.js format number with fixed width -


i playing around accounting.js , have problem it.

the problem encountered apply function in accounting called formatmoney on top of number number looks nice, also, keep number fixed width.

from know, in javascript, have function called toprecision(), transfer number fixed width format.

how can combine them together?

for example, if have number var number = 12345.67. applying number.toprecision(6), 12345.6. using accounting.formatmoney(12345.67, {precision:2}). 12,345.67. how can merge result of toprecision accounting.js desired number 12,345.6. (the precision vary according how big number not able alway pass precision value formatmoney).

any hint appreciated.

is you're after?

http://jsbin.com/dumuvavisu/1/edit?js,console

var number = 12345.67;  var = accounting.formatmoney(number.toprecision(6)) var b = a.substring(a.length-1,0);  console.log(b); // <-- "$12,345.7" 

Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -