I have multiple if statements that are being called upon. I want to set it so that if the user cancels all 4 prompts it will prompt them that it's invalid and return them to the beginning of the function? I tried to set it as an if statement, but could not quite get it to work.
I am kind of new to JavaScript so please bear with me or keep it simple.
// Get references to the #generate element
var generateBtn = document.querySelector("#generate");
const myArrayUpper = Array.from(Array(26)).map((e, i) => i + 65);
const alphabetUpper = myArrayUpper.map((x) => String.fromCharCode(x));
const myArrayLower = Array.from(Array(26)).map((e, i) => i + 97);
const alphabetLower = myArrayLower.map((x) => String.fromCharCode(x));
const arrayNumeric = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const arraySpecialCharacters = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')'];
function generatePassword() {
  var results = "";
  var numberOfCharacters = window.prompt("How many characters would you like your password to contain");
  var characterQuantity = parseInt(numberOfCharacters);
  if (characterQuantity >= 8 && characterQuantity <= 128) {
    var lowerCase = window.confirm("click OK to confirm lowercase letter.");
    var upperCase = window.confirm("Click OK to confirm uppercase letter.");
    var numeric = window.confirm("Click OK to confirm numeric values");
    var specialCharacters = window.confirm("Click OK to confirm special characters");
    var okayButton = [];
    if (upperCase == true) okayButton.push(alphabetUpper);
    if (lowerCase == true) okayButton.push(alphabetLower);
    if (numeric == true) okayButton.push(arrayNumeric);
    if (specialCharacters == true) okayButton.push(arraySpecialCharacters);
    for (var i = 0; i < characterQuantity; i++) {
      var storeButton = Math.floor(Math.random() * okayButton.length);
      var selectedArray = okayButton[storeButton];
      results += selectedArray[Math.floor(Math.random() * selectedArray.length)];
      // results += alphabetLower[Math.floor(Math.random() *26)];
      // results += arrayNumeric[Math.floor(Math.random() *10)];
      // results += arraySpecialCharacters[Math.floor(Math.random() *10)];
    }
  } else {
    window.alert('This is an invalid entry. Select an entry between 8 and 128');
    return generatePassword();
  }
  return results;
}
// challenge make it so that if they hit cancel to many times instead of error have it prompt them to do it again
// Write password to the #password input
function writePassword() {
  var password = generatePassword();
  var passwordText = document.querySelector("#password");
  passwordText.value = password;
}
// Add event listener to generate button
generateBtn.addEventListener("click", writePassword);<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Password Generator</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <div class="wrapper">
    <header>
      <h1>Password Generator</h1>
    </header>
    <div class="card">
      <div class="card-header">
        <h2>Generate a Password</h2>
      </div>
      <div class="card-body">
        <textarea readonly id="password" placeholder="Your Secure Password" aria-label="Generated Password"></textarea>
      </div>
      <div class="card-footer">
        <button id="generate" class="btn">Generate Password</button>
      </div>
    </div>
  </div>
  <script src="script.js"></script>
</body>
</html>

Array.from()inArray.from(Array(26))?Array(26)is guaranteed to return an array.Array.from()is for converting something that's array-like (e.g. a NodeList) to an actual array.Array.fromis necessary because, per the docs, "[map] is invoked only for indexes of the array which have assigned values."Array(26)creates an array of length 26 containing only empty items, soArray(26).map(...)would do nothing. It's worth noting that this is very javascript-specific. In most languages, creating an array will allocate it, even if the values in the resultant array are just whatever was in already memory at those locations.