assets/scripts/script.js
// Generate the password based on the password criteria
Generate the password based on the password criteria
Generate the password based on the password criteria
function generatePassword() {
  const length = lengthSlider.value;
  const passwordCriteria = getCriteria();
  let passwordOutput = "";
  if (passwordCriteria != null && passwordCriteria.length > 0) {
    for(var i = 0; i < length; i++) {
      let p = Math.floor(Math.random() * passwordCriteria.length);
      if (passwordCriteria[p] === "0") {
        passwordOutput = passwordOutput += getOptions("letters");
      }
      if (passwordCriteria[p] === "1") {
        passwordOutput = passwordOutput += getOptions("letters").toUpperCase();
      } 
      if (passwordCriteria[p] === "2") {
        passwordOutput = passwordOutput += getOptions("numbers");
      } 
      if (passwordCriteria[p] === "3") {
        passwordOutput = passwordOutput += getOptions("characters");
      } 
    }
  }
  return passwordOutput
}
function generatePassword ( ) { const length = lengthSlider . value ; const passwordCriteria = getCriteria ( ) ; let passwordOutput = "" ; if ( passwordCriteria != null && passwordCriteria . length > 0 ) { for ( var i = 0 ; i < length ; i ++ ) { let p = Math . floor ( Math . random ( ) * passwordCriteria . length ) ; if ( passwordCriteria [ p ] === "0" ) { passwordOutput = passwordOutput += getOptions ( "letters" ) ; } if ( passwordCriteria [ p ] === "1" ) { passwordOutput = passwordOutput += getOptions ( "letters" ) . toUpperCase ( ) ; } if ( passwordCriteria [ p ] === "2" ) { passwordOutput = passwordOutput += getOptions ( "numbers" ) ; } if ( passwordCriteria [ p ] === "3" ) { passwordOutput = passwordOutput += getOptions ( "characters" ) ; } } } return passwordOutput }
Generate the password based on the password criteria
Generate the password based on the password criteria
// Gather inputs from password criteria form // Gather the password criteria // Generate the password output // Return the generated password