Get random strings from given string In javascript

21-02-2017 javascript random string

The below function return a random string with given length

function randomString(length) {
    chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
    return result;
var res = randomString(4);


You might also like:

Detect AdBlock with JavaScript in my browser
30-07-2017 AdBlock javascript detect
How to upload file by using request module
18-03-2017 request module node js
Sanitization in java sript
14-03-2017 sanitization java script
How to make an http request in node js
14-03-2017 http module node js
How to convert html to pdf in Node js
12-03-2017 pdf convert html node js