Skip to content

Instantly share code, notes, and snippets.

@dimasmiftah
Last active January 30, 2021 07:27
Show Gist options
  • Save dimasmiftah/6bf5e8b01c0d5d9abbc7a08ee0ae8a54 to your computer and use it in GitHub Desktop.
Save dimasmiftah/6bf5e8b01c0d5d9abbc7a08ee0ae8a54 to your computer and use it in GitHub Desktop.
Generate random Telkomsel number based on a valid HLR
const HLRTelkomsel = {
jawaTimur: [
'6281130',
'6281131',
'6281132',
'6281133',
'6281134',
'6281137',
'6281135',
'6281136',
'6281216',
'6281217',
'6281230',
'6281231',
'6281232',
'6281233',
'6281234',
'6281235',
'6281249',
'6281252',
'6281259',
'6281330',
'6281331',
'6281332',
'6281333',
'6281334',
'6281335',
'6281336',
'6281357',
'6281358',
'6281359',
'6282139',
'6282140',
'6282141',
'6282142',
'6282143',
'6285230',
'6285231',
'6285232',
'6285233',
'6285234',
'6285235',
'6285236',
'6285257',
'6285258',
'6285259',
'6285330',
'6285331',
'6285332',
'6285333',
'6285334',
'6285335',
'6285336',
'6282228',
'6282229',
'6282230',
'6282231',
'6282232',
'6282233',
'6282234',
'6282264',
'6282330',
'6282331',
'6282332',
'6282333',
'6282334',
'6282335',
'6282336',
'6282337',
'6282338',
],
jawaTengah: [
'6281126',
'6281128',
'6281129',
'6281127',
'6281125',
'6281225',
'6281226',
'6281227',
'6281228',
'6281229',
'6281215',
'6281325',
'6281326',
'6281327',
'6281328',
'6281329',
'6281390',
'6281391',
'6281393',
'6282133',
'6282134',
'6282135',
'6282136',
'6282137',
'6282138',
'6282220',
'6282221',
'6282222',
'6282223',
'6282224',
'6282225',
'6282226',
'6282227',
'6282265',
'6282322',
'6282323',
'6282324',
'6282325',
'6282326',
'6282327',
'6282328',
'6282329',
'6285225',
'6285226',
'6285227',
'6285228',
'6285229',
'6285290',
'6285291',
'6285292',
'6285293',
'6285325',
'6285326',
'6285327',
'6285328',
'6285329',
],
jawaBarat: [
'6281112',
'6281120',
'6281121',
'6281122',
'6281123',
'6281124',
'6281211',
'6281212',
'6281214',
'6281220',
'6281221',
'6281222',
'6281223',
'6281224',
'6281312',
'6281313',
'6281320',
'6281321',
'6281322',
'6281323',
'6281324',
'6281394',
'6281395',
'6282115',
'6282116',
'6282117',
'6282118',
'6282119',
'628212',
'6282130',
'6282262',
'6282214',
'6282215',
'6282216',
'6282217',
'6282218',
'6282219',
'6282263',
'6282315',
'6282316',
'6282317',
'6282318',
'6282319',
'6282320',
'6282321',
'6285220',
'6285221',
'6285222',
'6285223',
'6285224',
'6285294',
'6285295',
'6285310',
'6285312',
'6285313',
'6285320',
'6285321',
'6285322',
'6285323',
'6285324',
],
sumateraBagianUtara: [
'6282272',
'6282273',
'6282274',
'6282275',
'6282276',
'6282277',
'6282267',
'6281168',
'6281167',
'6281160',
'6281163',
'6281164',
'6281165',
'6281260',
'6281261',
'6281262',
'6281263',
'6281264',
'6281265',
'6281269',
'6281360',
'6281361',
'6281362',
'6281370',
'6281375',
'6281376',
'6281377',
'6281396',
'6281397',
'6282160',
'6282161',
'6282162',
'6282163',
'6282164',
'6282165',
'6282166',
'6282167',
'6282168',
'6285260',
'6285261',
'6285262',
'6285270',
'6285275',
'6285276',
'6285277',
'6285296',
'6285297',
'6285360',
'6285361',
'6285362',
'6282360',
'6282361',
'6282362',
'6282363',
'6282364',
'6282365',
'6282366',
'6282367',
'6282368',
'6282369',
'6282370',
],
sumateraBagianTengah: [
'6282283',
'6282284',
'6282285',
'6282286',
'6282287',
'6282288',
'6282289',
'6282268',
'6281166',
'6281169',
'6281170',
'6281177',
'6281175',
'6281176',
'6281261',
'6281266',
'6281267',
'6281268',
'6281270',
'6281275',
'6281276',
'6281277',
'6281363',
'6281364',
'6281365',
'6281366',
'6281368',
'6281371',
'6281372',
'6281374',
'6282169',
'6282170',
'6282171',
'6282172',
'6282173',
'6282174',
'6285263',
'6285264',
'6285265',
'6285271',
'6285272',
'6285274',
'6285278',
'6285363',
'6285364',
'6285365',
'6285366',
'6285367',
'6285368',
'6285369',
'6282381',
'6282382',
'6282383',
'6282384',
'6282385',
'6282386',
'6282387',
'6282388',
'6282389',
'6282390',
'6282391',
'6282392',
],
sumateraBagianSelatan: [
'6282278',
'6282279',
'6282280',
'6282281',
'6282282',
'6282269',
'6281171',
'6281178',
'6281172',
'6281179',
'6281173',
'6281174',
'6281271',
'6281272',
'6281273',
'6281274',
'6281278',
'6281279',
'6281367',
'6281368',
'6281369',
'6281373',
'6281377',
'6281379',
'6282175',
'6282176',
'6282177',
'6282178',
'6282179',
'6282180',
'6282181',
'6282182',
'6282183',
'6282184',
'6282185',
'6282186',
'6285266',
'6285267',
'6285268',
'6285269',
'6285273',
'6282371',
'6282372',
'6282373',
'6282374',
'6282375',
'6282376',
'6282377',
'6282378',
'6282379',
'6282380',
],
jabodetabek: [
'6282298',
'6282299',
'6281110',
'6281111',
'6281113',
'6281114',
'6281115',
'6281116',
'6281117',
'6281118',
'6281119',
'628118',
'628119',
'6281210',
'6281213',
'6281218',
'6281219',
'628128',
'628129',
'6281310',
'6281311',
'6281313',
'6281314',
'6281315',
'6281316',
'6281317',
'6281318',
'6281319',
'628138',
'628139',
'6282110',
'6282111',
'6282112',
'6282113',
'6282114',
'6285210',
'6285213',
'6285214',
'6285215',
'6285216',
'6285217',
'6285218',
'6285219',
'628528',
'6285310',
'6285311',
'6285314',
'6285315',
'6285316',
'6285317',
'6285318',
'6285319',
'6282210',
'6282211',
'6282212',
'6282213',
'6282260',
'6282261',
'6282310',
'6282311',
'6282312',
'6282313',
'6282314',
],
baliDanNusaTenggara: [
'6282266',
'6281138',
'6281139',
'6281236',
'6281237',
'6281238',
'6281239',
'6281246',
'6281337',
'6281338',
'6281339',
'6281353',
'6282144',
'6282145',
'6282146',
'6282147',
'6285237',
'6285238',
'6285239',
'6285253',
'6285337',
'6285338',
'6285339',
'6282235',
'6282236',
'6282237',
'6282339',
'6282340',
'6282341',
'6282342',
],
kalimanatan: [
'6282145',
'6282146',
'6282147',
'6282148',
'6282149',
'6282150',
'6282151',
'6282152',
'6282153',
'6282154',
'6282155',
'6282156',
'6282157',
'6282158',
'6282159',
'6282245',
'6282246',
'6282247',
'6282248',
'6282249',
'6282250',
'6282251',
'6282252',
'6282253',
'6282254',
'6282255',
'6282256',
'6282257',
'6282258',
'6282259',
'6282345',
'6282346',
'6282347',
'6282348',
'6282349',
'6282350',
'6282351',
'6282352',
'6282353',
'6282354',
'6282355',
'6282356',
'6282357',
'6282358',
'6282359',
'6281245',
'6281246',
'6281247',
'6281248',
'6281249',
'6281250',
'6281251',
'6281252',
'6281253',
'6281254',
'6281255',
'6281256',
'6281257',
'6281258',
'6281259',
'6281345',
'6281346',
'6281347',
'6281348',
'6281349',
'6281350',
'6281351',
'6281352',
'6285245',
'6285246',
'6285247',
'6285248',
'6285249',
'6285250',
'6285251',
'6285252',
'6285345',
'6285346',
'6285347',
'6285348',
'6285349',
'6285350',
'6285351',
'6285352',
'6285353',
'6285354',
'6285355',
'6285356',
'6285357',
'6285358',
'6285359',
'6285151',
],
sulawesi: [
'6282290',
'6282291',
'6282292',
'6282293',
'6282294',
'6282295',
'6282296',
'6282271',
'6281140',
'6281141',
'6281142',
'6281143',
'6281144',
'6281145',
'6281146',
'6281241',
'6281242',
'6281243',
'6281244',
'6281245',
'62812475',
'62812476',
'62812477',
'62812478',
'62812479',
'6281340',
'6281341',
'6281342',
'62813435',
'62813436',
'62813437',
'62813438',
'62813439',
'62813542',
'62813543',
'62813544',
'62813545',
'62813546',
'62813547',
'62813548',
'62813549',
'6281355',
'6281356',
'6282187',
'6282188',
'6282189',
'6282190',
'6282191',
'6282192',
'6282193',
'6282194',
'6282195',
'6282196',
'6285240',
'6285241',
'6285255',
'6285256',
'6285298',
'6285299',
'6285340',
'6285341',
'6285342',
'62853435',
'62853436',
'62853437',
'62853438',
'62853439',
'6282258',
'6282259',
'6282343',
'6282344',
'6282345',
'6282346',
'6282347',
'6282348',
'6282349',
'6282393',
'6282394',
'6282395',
'6282396',
],
malukuDanPapua: [
'6282297',
'6281147',
'6281148',
'6281149',
'6281240',
'62812470',
'62812471',
'62812472',
'62812473',
'62812474',
'6281248',
'62813430',
'62813431',
'62813432',
'62813433',
'62813434',
'6281344',
'62813540',
'62813541',
'6282197',
'6282198',
'6282199',
'6285243',
'6285244',
'6285254',
'62853430',
'62853431',
'62853432',
'62853433',
'62853434',
'6285344',
'6285354',
'6282238',
'6282239',
'6282397',
'6282398',
'6282399',
],
};
const randomProperty = (obj) => {
const keys = Object.keys(obj);
return obj[keys[(keys.length * Math.random()) << 0]];
};
const randomElement = (array) => {
const idx = Math.floor(Math.random() * array.length)
return array[idx]
}
const makeItTwenty = (number) => {
let numberArray = number.split('')
for (let i=0; i<=17-numberArray.length; i++) {
const randomNumber = String(Math.floor(Math.random() * 10))
numberArray.push(randomNumber)
}
return numberArray.join('')
}
const randomRegion = randomProperty(HLRTelkomsel)
console.log(randomRegion)
const randomHLR = randomElement(randomRegion)
console.log(randomHLR)
const randomPhoneNumber = makeItTwenty(randomHLR)
console.log(randomPhoneNumber)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment