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

174
Views
Licencia Keygen en javascript

Entonces vi otra solución aquí con un problema que estaba teniendo. Aunque el problema no está completamente resuelto para mí.

Este es el código que encontré aquí.

 function makeid(length) { var result = ""; var characters = '0123456789'; for (var i = 0; i < length; i++) { result += characters[Math.floor(Math.random() * characters.length)]; } result = result.match(/\d{1,4}/g).join("-"); return result; } console.log(makeid(16));

Y este es el código actual que tengo ahora.

 function makeid(length) { var result = ""; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for (var i = 0; i < length; i++) { result += characters[Math.floor(Math.random() * characters.length)]; } result = result.match(/\d{1,4}/g).join("-"); return result; } console.log(makeid(16));

La salida es no quiero quiero. ¡Quiero que la salida sea tanto en Letras como en Números y no estoy seguro de por qué no hará ambas cosas!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es porque su match() solo busca dígitos ( \d ) y no cualquier carácter ( . ):

 function makeid(length) { var result = ""; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for (var i = 0; i < length; i++) { result += characters[Math.floor(Math.random() * characters.length)]; } result = result.match(/.{1,4}/g).join("-"); return result; } console.log(makeid(15));

Y puede deshacerse de la match lenta por completo, usando el operador % :

 function makeid(length) { var result = ""; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for (var i = 0; i < length; i++) { result += characters[Math.floor(Math.random() * characters.length)]; if (i+1 < length && !((i+1) % 4)) result += "-"; } return result; } console.log(makeid(16));

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!