Password Generator Tutorial
Page Six
Join the Discussion
More of This Feature
if (ffnc) charSet += numChars;
if (fflc) charSet += lowerChars;
if (ffuc) charSet += upperChars;
y = charSet.length;
We still need to select the first character for our password. We can reuse the charSet variable to determine the valid characters that we will select the first character from.
We now select a character at random from the list of valid first characters (using similar code to before) and push it onto the front of our array using the unshift method. All of the entries already in our array are automatically moved along into the next position to make room for the additional character on the front.
}
The final step is to convert the array to a character string using the join method. By not specifying a join character the contents of our array are concatenated directly together (had I not specified '' then they would have been comma separated). The character string containing our generated password is then loaded into the output field of our form. Finally we close off the password function. We don't need to return a value because we have already updated the form.

