joelnazarene

Untitled

Feb 20th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.59 KB | None | 0 0
  1.  
  2. <html>  
  3. <body>  
  4. <div>  
  5. Enter the length of character:
  6. <input type='text' id="num">  
  7. <button onclick="stringGen()">submit</button>
  8. <p id="result"></p>
  9. </div>
  10. <script type="text/javascript" >
  11.  
  12. function stringGen()
  13. {
  14.    //Type your code here.
  15.  
  16.   var lenn=document.getElementById("num");
  17.  
  18.    var arr='abcdefghijklmnopqrstuvwxyz0123456789';
  19.    
  20.   var a='';
  21.   for(let i=0;i<lenn;i++){
  22.     var pos=Math.random()*(35-0);
  23.    a=a+arr[pos];
  24.  
  25.  
  26.  
  27.  }
  28.  
  29.  document.getElementById("demo").innerHTML = a;
  30.   // return a; //Enter your return statement
  31. }
  32.  
  33.  
  34.  
  35. </SCRIPT>
  36. </body>  
  37. </html>
Add Comment
Please, Sign In to add comment