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

92
Views
Js novato aquí. Quiero que mis contraseñas incluyan al menos: 1 mayúscula, 1 carácter especial

Quería que mis contraseñas incluyeran al menos: 1 mayúscula, 1 carácter especial. Estoy intentando con este ciclo while cumplir con los requisitos. ¿Qué estoy haciendo mal?

 const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#$!-_"; const capital = /ABCDEFGHIJKLMNOPQRSTUVWXYZ/; const special = /#$!-_/; function PWord (){ let pass = "" while(!((capital.test(pass)) && (special.test(pass))) ){ for (i=0; i<=11; i++) { let rand_char = characters.charAt(Math.floor(Math.random()*characters.length)); pass = pass + rand_char; } return pass } } for(let i=0;i<=3;i++){ let ps = PWord(); console.log("Password" + (i+1) + ":" + ps); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema principal que veo aquí es el uso de return en el bucle while. return siempre finalizará la ejecución de toda la función y devolverá el valor especificado. La condición en su bucle solo se verificará una vez desde que regrese antes de darle la oportunidad de verificar y ejecutar nuevamente. Intenta mover esa línea fuera del bucle.

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!