JavaScript'te Rastgele ID Oluşturma

Rastgele bir id dizesi oluşturacak bir fonksiyon yapalım:

javascriptfunction getId(length = 16) {
  let chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  
  let res = '';
  
  for (let i = 0; i < length; i++) {
    res += chars[Math.floor(Math.random() * chars.length)];
  }
  
  return res;
}

Fonksiyonumuzu kullanalım:

javascriptlet id = getId();
console.log(id);
Задание 1

Verilen fonksiyonu kopyalayın ve çalışmasını test edin.