How to print a number in local string format with TypeScript

1 Answer

0 votes
const n: number = 8347523.9126;

console.log("Locale String: " + n.toLocaleString());

console.log("German: " + n.toLocaleString('de-DE'));

console.log("Arabic: " + n.toLocaleString('ar-EG'));

console.log("Swedish: " + n.toLocaleString('sv-SE'));

console.log("Mainland China: " + n.toLocaleString('zh-CN'));



 
 
     
     
/*
run:

"Locale String: 8,347,523.913" 
"German: 8.347.523,913" 
"Arabic: ٨٬٣٤٧٬٥٢٣٫٩١٣" 
"Swedish: 8 347 523,913" 
"Mainland China: 8,347,523.913" 
     
*/

 



answered Aug 12, 2022 by avibootz
edited Aug 12, 2022 by avibootz

Related questions

...