Random Password Generator in JavaScript

Random Password Generator in JavaScript

Source code :

function generatePassword(){
    

var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz~`!@#$%^&*()_+[]{};:?><,./";
var length = 18;
var randompassword = '';
var count = 0;
var numcount = 0;
var rnum

for (var i=0; i<length; i++) {
    if((Math.floor(Math.random() * 2) === 0) && numcount < 3 || count >= 5){
        rnum = Math.floor(Math.random() * 10);
        randompassword += rnum;
        numcount += 1;
    } 
    else{
        rnum = Math.floor(Math.random() * chars.length);
        randompassword += chars.substring(rnum,rnum+1);
        count += 1;
    }
}

return randompassword;

}

Output :

469x!S*C1862570756

Output :


                

Comments :