Random string generator function

a function to create random string with a specified length and containing only alpha numeric characters

by Lucas Krause

JavaScript

var fn_randomStr=function(int_lenght){
        int_lenght=(int_lenght!==undefined && int_lenght!==null) ? int_lenght : 20;
    
        var str_a="abcdefghijklmnopqrstuvwxyz",
            arr_a=(str_a+str_a.toUpperCase()+"0123456789").split(""),
            arr_b=[];
        
        for(var i=0; i<int_lenght; i++){
            arr_b.push(arr_a[Math.round(Math.random()*(arr_a.length-1))]);
        }
        
        return arr_b.join("");
    };

console.log(fn_randomStr());