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); alert(res);
You might also like:
Compare the Triplets | Javascript | hackerrank.com07-05-2020 hackerrank.com |
How to search text in string using php ?29-10-2017 php search string search |
Sanitization in java sript14-03-2017 sanitization java script |
How to find Angular Errors06-03-2017 errors angularjs exceptionHandler |
How to set or update or push the values into Object in javacript27-02-2017 javascript set update push object |