Sumber Kode

Change Number To Rupiah Format (Indonesian Currency)

  • anonymous
  • Apr 28' 14
  • Javascript
  • 1018
  • 7
  • United States

Example Number is 1234567, ti will be change to Rp. 1.234.567,00

syntax :

function ChangeToRupiah(angka){
    var rev     = parseInt(angka, 10).toString().split("").reverse().join("");
    var rev2    = "";
    for(var i = 0; i < rev.length; i++){
        rev2  += rev[i];
        if((i + 1) % 3 === 0 && i !== (rev.length - 1)){
            rev2 += ".";
        }
    }
    return "Rp. " + rev2.split("").reverse().join("") + ",00";
}

Share

  • Tags : rupiah, currency format, money
comments powered by Disqus

Kode Terkait

Curreny Number Format

Money to Text



Kategori