Home

Published

- 1 min read

javascript function to generate random alphanumeric string

img of javascript function to generate random alphanumeric string

The solution for this is noted below

javascript function to generate random alphanumeric string

Solution

   var characters = 'abcdefghijklmnopqrstuvwxyz0123456789'
var result = ''
var charactersLength = characters.length

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

console.log(result)

Try other methods by searching on the site. That is if this doesn’t work