How to format numbers as percentage values in JavaScript?

You can use Number.toLocaleString():

var num=25;
var s = Number(num/100).toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2}); 
console.log(s);

No ‘%’ sign needed, output is:

25.00%

See documentation for toLocaleString() for more options for the format object parameter.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)