var str=''; for(var i=0;i<5;i++){ var a=Math.floor(Math.random()*25+97); a=String.fromCharCode(a); str+=a; } alert(str);