Javascript String generate random string

Description

Javascript String generate random string



var randomString = function (len) {
  var text = '';
  var possible = 'abcdefghijklmnopqrstuvwxyz';

  for (var i = 0; i < len; i++) {
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  }/*from  ww  w . jav  a  2  s.c  o  m*/

  return text;
};

console.log(randomString(10));



PreviousNext

Related