“string acak JS” Kode Jawaban

Fungsi JavaScript menghasilkan string acak

//Create a function that returns a string, of a given length
const genRand = (len) => {
  return Math.random().toString(36).substring(2,len+2);
}

console.log(genRand(8));
//Expected output example: 4yg020wn
Lord Geir Andersen

string acak JS

function randomString(length) {
		var result           = '';
		var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+=-';
		var charactersLength = characters.length;
		for ( var i = 0; i < length; i++ ) {
		   result += characters.charAt(Math.floor(Math.random() * charactersLength));
		}
		return result;
	 }
randomString(4);
Dizzy Dove

JavaScript menghasilkan string acak

// program to generate random strings

const result = Math.random().toString(36).substring(2,7);
console.log(result);
Code_Breaker

menghasilkan string acak dalam javascript

function makeid(length) {
    var result           = '';
    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var charactersLength = characters.length;
    for ( var i = 0; i < length; i++ ) {
      result += characters.charAt(Math.floor(Math.random() * 
 charactersLength));
   }
   return result;
}

console.log(makeid(5));
|_Genos_|

node generator string acak js

function makeid(length) {
    var result           = [];
    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var charactersLength = characters.length;
    for ( var i = 0; i < length; i++ ) {
      result.push(characters.charAt(Math.floor(Math.random() * 
 charactersLength)));
   }
   return result.join('');
}

console.log(makeid(5));
Calm Crocodile

string acak JS

const random = 'abcdefghijklmnopqrstuvwxyz123456789'
const size = 8
let code = ""

for(let i = 1; i < size; i++) {
   code += random[Math.abs(Math.floor(Math.random() * random.length))]
}

console.log(code.toUpperCase())
Restu Wahyu Saputra

Jawaban yang mirip dengan “string acak JS”

Pertanyaan yang mirip dengan “string acak JS”

Lebih banyak jawaban terkait untuk “string acak JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya