“JavaScript string acak” 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

JavaScript string acak

const randomString = ()=>Math.random().toString(36) + Date.now().toString(36)
Husnain Syed

JavaScript string acak

it('should add random string into input field ', async () => {
    
    const characters ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    function generateString(length) {
        let result = ' ';
        const charactersLength = characters.length;
        for ( let i = 0; i < length; i++ ) {
            result += characters.charAt(Math.floor(Math.random() * charactersLength));
        }
    
        return result;
    }
    let input = await $('#email')
        await input.addValue(generateString(5))
    
        await browser.pause(4000);        
    })
Vivacious Vicuña

JavaScript string acak

strRandom({
  includeUpperCase: true,
  includeNumbers: true,
  length: 5,
  startsWithLowerCase: true
});
Puzzled Penguin

Jawaban yang mirip dengan “JavaScript string acak”

Pertanyaan yang mirip dengan “JavaScript string acak”

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

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya