Guest User

Untitled

a guest
Oct 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function randomString(len, matrix='qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM_-.#@'){
  2. var ret='';
  3. for(var i=0;i<len;i++){
  4. ret+=matrix.charAt(Math.floor(Math.random()*matrix.length));
  5. }
  6. return ret;
  7. }
  8.  
  9.  
  10. /*
  11. EXAMPLE BEGINE
  12. */
  13. console.log(randomString(7));
  14. console.log(randomString(3));
  15. console.log(randomString(30));
  16. console.log(randomString(9), "1234567890");
  17. console.log(randomString(13), ",./;'[]-=\\|}{+_:\"?><");
  18. /*
  19. EXAMPLE END
  20. */
Add Comment
Please, Sign In to add comment