function guid (l) {
if(l === undefined){
l = 32;
}
var ascii = '';
for(var x=0; x<l; x++){
var rnd = Math.floor(Math.random()*(122 - 48))+48;
var convert = String.fromCharCode(rnd);
if(!(convert.match(/[a-zA-Z0-9]/g))){
// how to return 'rnd' until the lenght of the parameter is complete
}else{
ascii += convert;
}
}
return ascii;
}
console.log(guid());
This is my code. Can u give me advice how to execute my if statement ? My output now is based on how many times rnd passes the if statement.
Aucun commentaire:
Enregistrer un commentaire