FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 16   



Following program shows you how to generate random string.
This program gets string length from user and prints random string of the given length

var stringLength = prompt("Please enter the string length:")
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var result = '';
for (var i = 1; i <= stringLength; i++) {
result = result + alphabet.charAt(Math.floor(Math.random() * alphabet.length))
}
console.log("Random string is: " + result);

Output:

Please enter the string length:
10
AwcNqKwhil



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News