script.js
// when user presses generate password button, the prompts will start
when user presses generate password button, the prompts will start
when user presses generate password button the prompts will start
function startPrompts() {
  var confirmNumbers = confirm('Would you like your password to include numbers?');
  var confirmLowercase = confirm('Would you like your password to include lowercase characters?');
  var confirmUppercase = confirm('Would you like your password to include uppercase characters?');
  var confirmSpecialChar = confirm('Would you like your password to include special characters (such as @#$%!)');
  var confirmLength = prompt('How many characters would you like your password to be? Please only enter numbers');
  if (confirmNumbers) {
    selected.push(numbersArray);
  }
  if (confirmLowercase) {
    selected.push(lowercaseArray);
  }
  if (confirmUppercase) {
    selected.push(uppercaseArray);
  }
  if (confirmSpecialChar) {
    selected.push(specialCharArray);
  }
  if (confirmNumbers === false && confirmLowercase === false && confirmUppercase === false && confirmSpecialChar === false) {
    alert('Please choose at least one character set for your password. Click \'generate password\' again!');
    location.reload();
  }
    var merged = [].concat.apply([], selected);
    generatePassword(confirmLength, merged);
  }
function startPrompts ( ) { var confirmNumbers = confirm ( 'Would you like your password to include numbers?' ) ; var confirmLowercase = confirm ( 'Would you like your password to include lowercase characters?' ) ; var confirmUppercase = confirm ( 'Would you like your password to include uppercase characters?' ) ; var confirmSpecialChar = confirm ( 'Would you like your password to include special characters (such as @#$%!)' ) ; var confirmLength = prompt ( 'How many characters would you like your password to be? Please only enter numbers' ) ; if ( confirmNumbers ) { selected . push ( numbersArray ) ; } if ( confirmLowercase ) { selected . push ( lowercaseArray ) ; } if ( confirmUppercase ) { selected . push ( uppercaseArray ) ; } if ( confirmSpecialChar ) { selected . push ( specialCharArray ) ; } if ( confirmNumbers === false && confirmLowercase === false && confirmUppercase === false && confirmSpecialChar === false ) { alert ( 'Please choose at least one character set for your password. Click \'generate password\' again!' ) ; location . reload ( ) ; } var merged = [ ] . concat . apply ( [ ] , selected ) ; generatePassword ( confirmLength , merged ) ; }
when user presses generate password button, the prompts will start
when user presses generate password button the prompts will start
// if the user clicks ok on the confirm, the corresponding array is pushed to 'selected' array // if the user clicks cancel on every confirm, they are instructed to choose at least one character set and the page reloads // concatonating all of the arrays the user selected into one merged array