NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// TERBILANG JS
var daftarAngka = new Array("","Satu","Dua","Tiga","Empat","Lima","Enam","Tujuh","Delapan","Sembilan");
function terbilang(nilai){
var temp='';
var hasilBagi,sisaBagi;
//batas untuk ribuan
var batas=3;
//untuk menentukan ukuran array, jumlahnya sesuaikan dengan jumlah anggota dari array gradeNilai[]
var maxBagian = 5;
// var gradeNilai=new Array("Rupiah","Ribu","Juta","Milyar","Triliun");
var gradeNilai=new Array("","Ribu","Juta","Milyar","Triliun");
//cek apakah ada angka 0 didepan ==> 00098, harus diubah menjadi 98
nilai = this.hapusNolDiDepan(nilai);
var nilaiTemp = ubahStringKeArray(batas, maxBagian, nilai);
//ubah menjadi bentuk terbilang
var j = nilai.length;
//menentukan batas array
var banyakBagian = (j % batas) == 0 ? (j / batas) : Math.round(j / batas + 0.5);
var h=0;
for(var i = banyakBagian - 1; i >=0; i-- ){
var nilaiSementara = parseInt(nilaiTemp[h]);
if (nilaiSementara == 1 && i == 1){
temp +="Seribu ";
}
else {
temp +=this.ubahRatusanKeHuruf(nilaiTemp[h])+" ";
// cek apakah string bernilai 000, maka jangan tambahkan gradeNilai[i]
if(nilaiTemp[h] != "000"){
temp += gradeNilai[i]+" ";
}
}
h++;
}
return temp;
}
function ubahStringKeArray(batas, maxBagian,kata){
// maksimal 999 milyar
var temp= new Array(maxBagian);
var j = kata.length;
//menentukan batas array
var banyakBagian = (j % batas) == 0 ? (j / batas) : Math.round(j / batas + 0.5);
for(var i = banyakBagian - 1; i >= 0 ; i--){
var k = j - batas;
if(k < 0) k = 0;
temp[i]=kata.substring(k,j);
j = k ;
if (j == 0)
break;
}
return temp;
}

function ubahRatusanKeHuruf(nilai){
//maksimal 3 karakter
var batas = 2;
//membagi string menjadi 2 bagian, misal 123 ==> 1 dan 23
var maxBagian = 2;
var temp = this.ubahStringKeArray(batas, maxBagian, nilai);
var j = nilai.length;
var hasil="";
//menentukan batas array
var banyakBagian = (j % batas) == 0 ? (j / batas) : Math.round(j / batas + 0.5);
for(var i = 0; i < banyakBagian ;i++){
//cek string yang memiliki panjang lebih dari satu ==> belasan atau puluhan
if(temp[i].length > 1){
//cek untuk yang bernilai belasan ==> angka pertama 1 dan angka kedua 0 - 9, seperti 11,16 dst
if(temp[i].charAt(0) == '1'){
if(temp[i].charAt(1) == '1') {
hasil += "Sebelas";
}
else if(temp[i].charAt(1) == '0') {
hasil += "Sepuluh";
}
else hasil += daftarAngka[temp[i].charAt(1) - '0']+ " Belas ";
}
//cek untuk string dengan format angka pertama 0 ==> 09,05 dst
else if(temp[i].charAt(0) == '0'){
hasil += daftarAngka[temp[i].charAt(1) - '0'] ;
}
//cek string dengan format selain angka pertama 0 atau 1
else
hasil += daftarAngka[temp[i].charAt(0) - '0']+ " Puluh " +daftarAngka[temp[i].charAt(1) - '0'] ;
}
else {
//cek string yang memiliki panjang = 1 dan berada pada posisi ratusan
if(i == 0 && banyakBagian !=1){
if (temp[i].charAt(0) == '1')
hasil+=" Seratus ";
else if (temp[i].charAt(0) == '0')
hasil+=" ";
else hasil+= daftarAngka[parseInt(temp[i])]+" Ratus ";
}
//string dengan panjang satu dan tidak berada pada posisi ratusan ==> satuan
else hasil+= daftarAngka[parseInt(temp[i])];
}
}
return hasil;
}
function hapusNolDiDepan(nilai){
while(nilai.indexOf("0") == 0){
nilai = nilai.substring(1, nilai.length);
}
return nilai;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.