javascript random password generator exampe

Solutions on MaxInterview for javascript random password generator exampe by the best coders in the world

showing results for - "javascript random password generator exampe"
Elena
25 May 2018
1/**
2 * Get Auto Generated Random Password
3 * 
4 * @param   int     length, eg: Default Length = 10
5 * 
6 * @return  string  Auto generated random password
7 */
8const getAutoGeneratedPassword = (length = 10) => {
9    const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
10          genPass = "";
11
12    for (let i = 0, n = charset.length; i < length; ++i) {
13        genPass += charset.charAt(Math.floor(Math.random() * n));
14    }
15
16    return genPass;
17}