Advertisement
NubeColectiva

Como Crear un OTP con números y letras en JavaScript !

Feb 10th, 2023
1,689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function crearOTP() {
  2.     const caracteres = '0123456789abcdefghijklmnopqrstuvwxyz';
  3.     let otp = "";
  4.     for (let i = 6; i > 0; i--) {
  5.         otp += caracteres[Math.floor(Math.random() * caracteres.length)];
  6.     }
  7.     return otp;
  8. }
  9.  
  10. crearOTP();
  11.  
  12. // Output (Resultado)
  13. 'random OTP'
Tags: JavaScript js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement