Created
February 25, 2022 08:37
-
-
Save yogasw/0fcc97487a4c3151ae12cda4e258b68b to your computer and use it in GitHub Desktop.
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
function printCurrency(number) { | |
// Nine Zeroes for Trillion | |
let value = Math.abs(Number(number)) >= 1.0e+12 | |
? (Math.abs(Number(number)) / 1.0e+12).toFixed(1) + " Triliun" | |
: Math.abs(Number(number)) >= 1.0e+9 | |
? (Math.abs(Number(number)) / 1.0e+9).toFixed(1) + " Miliar" | |
// Six Zeroes for Millions | |
: Math.abs(Number(number)) >= 1.0e+6 | |
? (Math.abs(Number(number)) / 1.0e+6).toFixed(1) + " Juta" | |
// Three Zeroes for Thousands | |
: Math.abs(Number(number)) >= 1.0e+3 | |
? (Math.abs(Number(number)) / 1.0e+3).toFixed(1) + " Ribu" | |
: Math.abs(Number(number)); | |
console.log(value) | |
} | |
printCurrency(number1) | |
printCurrency(number2) | |
printCurrency(number3) | |
printCurrency(number4) | |
printCurrency(number5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment