Answers for "generate random characters in javascript"

3

generate random character in javascript

var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var result = ""
var chaactersLength = characters.length;

for ( var i = 0; i < 5 ; i++ ) {
    result += characters.charAt(Math.floor(Math.random() * chaactersLength));
}

console.log(result)
Posted by: Guest on January-15-2021
23

javascript generate random string

var crypto = require("crypto");
var id = crypto.randomBytes(20).toString('hex');

// "bb5dc8842ca31d4603d6aa11448d1654"
Posted by: Guest on July-16-2020
10

javascript get random string

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

//usage: getRandomString(20); // pass desired length of random string
Posted by: Guest on July-23-2019
1

javascript random char

const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
function generateRandomCode(){
    let result = ""
    let charactersLength = characters.length;
    for ( var i = 0; i < 6 ; i++ ) {
        result += characters.charAt(Math.floor(Math.random() * charactersLength));
    }
    return result
}
Posted by: Guest on April-19-2021
0

random alphabet javascript

Math.random().toString(36).substr(2, 5);
Posted by: Guest on June-21-2020

Code answers related to "generate random characters in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language