Skip to content

Instantly share code, notes, and snippets.

@pujansrt
Last active March 24, 2019 06:23
Show Gist options
  • Save pujansrt/ec8977691dc6734f5d8ccec8e663165f to your computer and use it in GitHub Desktop.
Save pujansrt/ec8977691dc6734f5d8ccec8e663165f to your computer and use it in GitHub Desktop.
Generate Random Password (JS)
const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split('');
function generatePassword(L){
return Array.from({length: L})
.map(i => alphabet[Math.floor(Math.random() * alphabet.length)])
.join("")
}
console.log(generatePassword(14));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment