zet-lib 1.2.102 → 1.2.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Util.js +35 -0
- package/package.json +1 -1
package/lib/Util.js
CHANGED
|
@@ -1275,4 +1275,39 @@ Util.decrypt = (str, key) => {
|
|
|
1275
1275
|
return s + decrypt.final('utf8')
|
|
1276
1276
|
}
|
|
1277
1277
|
|
|
1278
|
+
Util.terbilang = (nilai) => {
|
|
1279
|
+
nilai = Math.floor(Math.abs(nilai))
|
|
1280
|
+
let huruf = ['', 'Satu', 'Dua', 'Tiga', 'Empat', 'Lima', 'Enam', 'Tujuh', 'Delapan', 'Sembilan', 'Sepuluh', 'Sebelas']
|
|
1281
|
+
let bagi = 0
|
|
1282
|
+
let penyimpanan = ''
|
|
1283
|
+
if (nilai < 12) {
|
|
1284
|
+
penyimpanan = ' ' + huruf[nilai]
|
|
1285
|
+
} else if (nilai < 20) {
|
|
1286
|
+
penyimpanan = terbilang(Math.floor(nilai - 10)) + ' Belas'
|
|
1287
|
+
} else if (nilai < 100) {
|
|
1288
|
+
bagi = Math.floor(nilai / 10)
|
|
1289
|
+
penyimpanan = terbilang(bagi) + ' Puluh' + terbilang(nilai % 10)
|
|
1290
|
+
} else if (nilai < 200) {
|
|
1291
|
+
penyimpanan = ' Seratus' + terbilang(nilai - 100)
|
|
1292
|
+
} else if (nilai < 1000) {
|
|
1293
|
+
bagi = Math.floor(nilai / 100)
|
|
1294
|
+
penyimpanan = terbilang(bagi) + ' Ratus' + terbilang(nilai % 100)
|
|
1295
|
+
} else if (nilai < 2000) {
|
|
1296
|
+
penyimpanan = ' Seribu' + terbilang(nilai - 1000)
|
|
1297
|
+
} else if (nilai < 1000000) {
|
|
1298
|
+
bagi = Math.floor(nilai / 1000)
|
|
1299
|
+
penyimpanan = terbilang(bagi) + ' Ribu' + terbilang(nilai % 1000)
|
|
1300
|
+
} else if (nilai < 1000000000) {
|
|
1301
|
+
bagi = Math.floor(nilai / 1000000)
|
|
1302
|
+
penyimpanan = terbilang(bagi) + ' Juta' + terbilang(nilai % 1000000)
|
|
1303
|
+
} else if (nilai < 1000000000000) {
|
|
1304
|
+
bagi = Math.floor(nilai / 1000000000)
|
|
1305
|
+
penyimpanan = terbilang(bagi) + ' Miliar' + terbilang(nilai % 1000000000)
|
|
1306
|
+
} else if (nilai < 1000000000000000) {
|
|
1307
|
+
bagi = Math.floor(nilai / 1000000000000)
|
|
1308
|
+
penyimpanan = terbilang(nilai / 1000000000000) + ' Triliun' + terbilang(nilai % 1000000000000)
|
|
1309
|
+
}
|
|
1310
|
+
return penyimpanan
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1278
1313
|
module.exports = Util
|