Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 585 Bytes

random_string.md

File metadata and controls

17 lines (12 loc) · 585 Bytes

Generate random string

var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var str = '';
for ( var i = 0; i < 10; i++ ) str += chars.charAt(Math.floor(Math.random() * chars.length));
  • var chars - declare characters string to use for random generation
  • var str - declare our resulting variable, will contain random string
  • 10 - length of random string
  • chars.charAt(Math.floor(Math.random() * chars.length)) - return random character from our chars

group: random_generate

link_youtube: https://youtu.be/UyX_fvabXyw