Advertisements

Generate random password in JavaScript

Advertisements

Generate random password in javascript

function randomPassword(passwordLength=8)
{
	var charsAllowed = "[email protected]#%~*"; 
	var len = passwordLength;
	var password = "";
	while (len--)
	{
		password+=charsAllowed.charAt(Math.floor(Math.random()*charsAllowed.length));
	}
	return password;
}

click for more JavaScript codes read about javascript random.