JSFiddle - React, Tailwind, and code Playground
by kosmos
JavaScript
var GenRandom = {
Stored: [],
Job: function(){
var newId = Date.now().toString().substr(6); // or use any method that you want to achieve this string
if( !this.Check(newId) ){
this.Stored.push(newId);
return newId;
}
return this.Job();
},
Check: function(id){
for( var i = 0; i < this.Stored.length; i++ ){
if( this.Stored[i] == id ) return true;
}
return false;
}
};
$(function(){
for( var i = 0; i < 10; i++ ){
$('body').append(GenRandom.Job() + '<br />');
}
});