Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
¿Hay alguna manera de hacer referencia a todas mis cadenas en una matriz en un bucle for () para asegurarse de que el usuario cumpla con los criterios para seleccionar una letra mayúscula?

Estoy tratando de crear indicaciones para que un usuario elija si desea que su contraseña contenga caracteres especiales, números en mayúsculas y minúsculas, etc. Creé matrices para ellos, pensé que era la forma más conveniente; sin embargo, necesito ayuda para hacer referencia a las matrices para crear la lógica correcta. (Me quedé atascado en donde ves el bucle for)

 // 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 answers
Answer question

0

Simplemente elimine el bucle for y use el método de test así

 if (/[AZ]/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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!