erknrio
7/9/2015 - 5:26 PM

Generar cadena aleatoria. Generar string aleatorio.

Generar cadena aleatoria. Generar string aleatorio.

function randomString(numChars, possible) {
  var text = "",
      i;

  possible = possible || "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.";
  numChars = numChars || 5;

  for (i = 0; i < numChars; i++) {
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  }

  return text;
}
// Random entre 1 y 10
var randomString = ((Math.random() * 10) +1).toString(32);