Random coupon code generator

Nice code to create a random coupon code.


export function button269_click(event) {
let grup= "";
 for (var i = 0; i < 8; i++) {   
 let text = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
     number = Math.floor((Math.random() * 62) + 1);
grup =grup + text.charAt(number)
}
console.log(grup);

}

Thanks for sharing! I wonder how it is possible to save in database who generated the code from site members?

Like any normal save, ‘insert’ is automatically saved to the author.