Generating a Random id in JavaScript

Let's create a function that will generate a string with a random id:

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;
}

Let's use our function:

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

Copy the provided function and test its operation.