You do not need to use repeat structures to generate alphanumeric values. Just use a base in the toString
function, for example:
let first = Math.random() // Gera um valor randômico
.toString(36) // Utiliza a Base36
.substr(-4) // Captura os 4 últimos números
.toUpperCase(); // Converte para maiúscula
let last = Math.floor((Math.random() * (9999 - 1000)) + 1000); // Gera um valor entre 999 e 10000
console.log( '${first}-${last}' )
The Base36 is a numerical system made up of arabic numerals from 0 to 9, and a hexadecimal number. of letters of the Latin alphabet from A to Z, ex: 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, (For example, if you want to change the color of the page, you can change the color of the letter).
for (let num = 0; num <= 35; num++) {
var a = num.toString(); // Decimal
var b = num.toString(2); // Binário
var c = num.toString(8); // Octal
var d = num.toString(16); // Hexadecimal
var e = num.toString(36); // Hexatrigesimal
var n = a + " | " + b + " | " + c + " | " + d + " | " + e + "<br><br>";
document.body.innerHTML += n;
}