100-project-100-days-website/100_projects/11-generate-random-serial-number/main.js
2023-03-04 17:14:11 +03:00
Ask

12 lines
419 B
JavaScript

{16d882b7fc4a0bf2d5bd903067620c78834d7903 true 419 main.js 0xc00c750b60}

let btnEl = document.querySelector('.generate');
let serialEl = document.querySelector('.serial');
btnEl.onclick = function(){
let chars = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
let charsCount = 15;
let randomSerial = "";
for (let i = 0; i < charsCount; i++){
randomSerial += chars[Math.floor(Math.random() * chars.length)];
}
serialEl.innerHTML = randomSerial;
};