Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
const s = ((n) => {
const alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let s = "";
for (let i = 0; i < n; i += 1) {
s += alphanum[~~(Math.random() * alphanum.length)];
}
return s;
})(n);
public static String generateValues(int n)
{
String alphabet1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String alphabet2 = "abcdefghijklmnopqrstuvwxyz";
String digits = "0123456789";
String values = alphabet1 + alphabet2 + digits;
Random random = new Random(1);
String s = "";
for(int count = 0; count < n; count++) {
s += String.valueOf(values.charAt(random.nextInt(values.length())));
}
return s;
}
function RandomString(Size: Integer): String;
const
Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
Len = Length(Chars);
var
i: Integer;
begin
Result := '';
SetLength(Result, Size);
for i := 1 to Size do
begin
Result[i] := Chars[Random(Len)+1];
end;
end;
my @chars = ('A'..'Z', 'a'..'z', '0'..'9');
my $s='';
$s .= $chars[int rand @chars] for 1..$n;