Random String Generator

node v8.11.3
version: 3.1.1
endpointsharetweet
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
function randomString(length){ var string = '' for (var i = 0; i < length; i++){ string += characters.charAt(Math.floor(Math.random() * characters.length)); } return string; }
randomString(10)
randomString(100);
randomString(1000);
randomString(10000);
randomString(1000000)
function twoRandoms(length){ return nRandoms(2, length); }
function nRandoms(n, length) { var outputArray = []; for (var i = 0, i < n, i++){ outputArray.push(randomString(length)); } return outputArray; }
module.exports = { randomString, twoRandoms, nRandoms, };
Loading…

no comments

    sign in to comment