Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Is there a way to reference all my strings in an array in a for() loop to make sure user meets criteria for selecting an uppercase letter

I am trying to create prompts for a user to choose if he would like his/her password to contain special characters, uppercase numbers, and lowercase numbers etc.. I created arrays for them, I figured that is the most convenient way; however, I need help in referencing the arrays to create the correct logic. (I got stuck on where you see the for loop)

// Assignment code here
document.querySelector('#generate').addEventListener("click", writePassword);

//Defined Array to full fill all the criteria options
var upper = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var lower = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
var special = ["`", "~", "!", "@","#","$","%","^","&","*","(",")","-","_","=","+","{","}","|", "[","]","<",">","?","/","'",];
var number = ["1","2","3","4","5","6","7","8","9","0"];

//Variables assigned
var passwordLength;
var upperConfirm;
var lowerConfirm;
var specialConfrim;
var numberConfirm;

// Get references to the #generate element
var generateBtn = document.querySelector("#generate");

// Write password to the #password input
function writePassword() {

  //prompt that asks for user to enter correct password length
  var passwordLength = window.prompt( "Please enter a password length between 8 and 128 characters.");
      if(passwordLength >= 8 || passwordLength <= 128){
        console.log(passwordLength);
        window.confirm("hit 'Okay' to confirm if you want your password to be this length.");
      }else{
        alert("Please enter a password length between 8 and 128 characters.")
      }
      //requirement for password to have upper case charachter
  var upperConfirm = window.prompt( "Please enter a password that contains an Upper case Character");
      for (var i = 0; i < upper.length; i++){
        console.log()
      }



    
  var password = generatePassword();
  var passwordText = document.querySelector("#password");

  passwordText.value = password; 

}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just remove the for loop and use the test method like so

if (/[A-Z]/g.test(upperConfirm) ){
    // includes an uppercase character password
}else{
    alert("Please enter a password that has an uppercase character.")
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda