“JS format ceny indyjskiej z przecinkami” Kod odpowiedzi

Sformatuj pieniądze JavaScript Comas

function formatMoney(n) {
    return "$ " + (Math.round(n * 100) / 100).toLocaleString();
}

n = 2123000;
// =>2,123,000
Zidane (Vi Ly - VietNam)

JS format ceny indyjskiej z przecinkami

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);
MrMalfunction

Odpowiedzi podobne do “JS format ceny indyjskiej z przecinkami”

Pytania podobne do “JS format ceny indyjskiej z przecinkami”

Więcej pokrewnych odpowiedzi na “JS format ceny indyjskiej z przecinkami” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu