Last active
December 6, 2021 10:20
-
-
Save bintangmuh/b7cf05fd3c0bbdd77c4fd314520034aa to your computer and use it in GitHub Desktop.
Rupiah number formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const convertToRupiah = (angka) => { | |
var rupiah = ''; | |
var angkarev = angka.toString().split('').reverse().join(''); | |
for(var i = 0; i < angkarev.length; i++) if(i%3 == 0) rupiah += angkarev.substr(i,3)+'.'; | |
return rupiah.split('',rupiah.length-1).reverse().join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment