JSFiddle - React, Tailwind, and code Playground
by Emily Humphrey
JavaScript
var createId = {
char: "abcdefghijklmnopqrstuvwxyz0123456789".split(""),
idMax: 20,
newId: function(){
var id = "";
for(var i = 0, x = this.idMax; i < x; i++){
id += this.random(2,1) > 1 ? this.randomChar().toUpperCase() : this.randomChar() ;
}
return id;
},
randomChar: function(){
return this.char[this.random(this.char.length-1)];
},
random: function(max, min){
min = min === undefined ? 0 : min;
return Math.floor(Math.random() * (max - min + 1)) + min;
},
};
console.log(createId.newId())