Kode JS:
fungsi s20 () {var data = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; untuk (var j = 0; j <500; j ++) {// 500 adalah jumlah baris yang akan dihasilkan var result = ""; untuk (var i = 0; i <20; i ++) {// menghasilkan 20 bit untuk membuat i <20r = math.floor (math.random ()*16); // 16 adalah jumlah data dalam array, tujuannya adalah menggunakan indeks saat ini untuk mendapatkan nilai dalam data array! hasil+= data [r]; // Saat mengeluarkan 20 angka acak, tambahkan RRR 20 kali, itu adalah string acak 20-bit. } document.write (hasil); document.write ("<br/>"); }}Lengkapi kode HTML:
<html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <itement> </iteme> <script type = "text/javascript"> function s20 () {var Data = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; untuk (var j = 0; j <500; j ++) {var result = ""; untuk (var i = 0; i <20; i ++) {r = math.floor (math.random ()*16); hasil+= data [r]; } document.write (hasil); document.write ("<br/>"); }} </script> </head> <body> <input type = "tombol" ontClick = "s20 ()" value = "menghasilkan nomor acak"> </body> </html>