1
I would like you not to repeat the values, and click show the code already without repetition
var vetor = [];
var auxiliaProtocolo = document.querySelector(".type");
var limiteMaximo = CheckMaxProtocol();
var botao = document.querySelector(".botao");
botao.addEventListener("click", function() {
var verificadorVetorCheio = verificaTotalVetor(vetor);
if (verificadorVetorCheio == true) {
return;
}
var resultado = geraProtocolo();
vetor.push(resultado);
for (var i = 0; i < vetor.length; i++) {
for (var j = i + 1; j < vetor.length; j++) {
if (vetor[i] == vetor[j]) {
vetor.pop(vetor[j]);
var result = geraProtocolo();
if (vetor[i] != result) {
vetor.push(result);
break;
}
}
}
}
});
var botao2 = document.querySelector(".botao2");
botao2.addEventListener("click", function() {
if (vetor.length > 0) {
var novoProtoco = document.createElement("p");
auxiliaProtocolo.appendChild(novoProtoco);
novoProtoco.innerHTML = "Protocolo: " + vetor;
}
});
You can join HTML and explain what should happen to reproduce the problem?
– Sergio
A non-repeating number is an auto_increment or rather complex randomness algorithm (which would be in your case with js).
– Leonardo Bonetti