“JavaScript -Zahlenformat indische Währung” Code-Antworten

JavaScript -Formatwährung

function formatToCurrency(amount){
    return (amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); 
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"
Pro___coder$

JavaScript -Zahlenformat indische Währung

(1234567.8).toFixed(2).replace(/(\d)(?=(\d{2})+\d\.)/g, '$1,') // "12,34,567.80"
amit.bhagat

Konvertieren Sie die Nummer in das indische Rupie -Format in JavaScript

    var x=12345678;
    x=x.toString();
    var lastThree = x.substring(x.length-3);
    var otherNumbers = x.substring(0,x.length-3);
    if(otherNumbers != '')
        lastThree = ',' + lastThree;
    var res = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
    alert(res);
Confused Chinchilla

Ähnliche Antworten wie “JavaScript -Zahlenformat indische Währung”

Fragen ähnlich wie “JavaScript -Zahlenformat indische Währung”

Weitere verwandte Antworten zu “JavaScript -Zahlenformat indische Währung” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen