script.js
// Write password to the #password input
Write password to the #password input
Write password to the #password input
function generatePassword() {
  var passwordLength = window.prompt("How long would you like your password to be? (8-128)")
  while (passwordLength < 8 || passwordLength > 128) {
    passwordLength = prompt("Please enter a number between 8 and 128.")
    console.log(passwordLength)
  }
  var useLowerCase = confirm ("Do you want to use lowercase letters?")
  var useUpperCase= confirm ("Do you want to use uppercase letters?")
  var useNumbers = confirm ("Do you want to include numbers in your password?")
  var useSpecials = confirm ("Do you want to include special characters in your password?")
var string = ""
  for (let i = 0; i < passwordLength;) {
var random = Math.random()
    if (random >.75 && useUpperCase) {
      string += getUpperCase()
    i++
    }
   else if (random >.5 && useLowerCase) {
      string += getLowerCase()
    i++
    }
   else if (random > .25 && useNumbers) {
      string += getNumbers()
    i++
    }
    else if (random > 0 && useSpecials) {
      string += getSpecials()
    i++
    }
  }
  return string;
}
function generatePassword ( ) { var passwordLength = window . prompt ( "How long would you like your password to be? (8-128)" ) while ( passwordLength < 8 || passwordLength > 128 ) { passwordLength = prompt ( "Please enter a number between 8 and 128." ) console . log ( passwordLength ) } var useLowerCase = confirm ( "Do you want to use lowercase letters?" ) var useUpperCase = confirm ( "Do you want to use uppercase letters?" ) var useNumbers = confirm ( "Do you want to include numbers in your password?" ) var useSpecials = confirm ( "Do you want to include special characters in your password?" ) var string = "" for ( let i = 0 ; i < passwordLength ; ) { var random = Math . random ( ) if ( random > .75 && useUpperCase ) { string += getUpperCase ( ) i ++ } else if ( random > .5 && useLowerCase ) { string += getLowerCase ( ) i ++ } else if ( random > .25 && useNumbers ) { string += getNumbers ( ) i ++ } else if ( random > 0 && useSpecials ) { string += getSpecials ( ) i ++ } } return string ; }
Write password to the #password input
Write password to the #password input