javascript

Generate Unique ID

const uuid = (lenght = 10) =>{
    const charts = "abcdefghijklmnopqrstuvwzywABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
    let id = "";
    
    for(let i = 0 ; i < lenght;i++){
        id += charts[Math.floor(Math.random() * charts.length)];
    }
    return id;
}

Create a random unique id 

Was this helpful?