Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Preventing a generator from repeating options until all options are exhausted?

I feel I should preface this by saying I am just now really learning how to incorporate anything into JavaScript, so please explain things and answers at a rudimentary level.

I am trying to figure out how to make this script NOT REPEAT an option until ALL options have been exhausted at least once. This is a common problem with Math.random from what I see, but I have no idea how to incorporate a fix to make it not repeat.

var roulette = document.getElementById("rouletteButton");
var stratnames_t = {
  '0': "Strategy 1 Name Here",
  '1': "Strategy 2 Name Here",
};
var objectives_t = {
  '0': "Objective 1 Description Here",
  '1': "Objective 2 Description Here",
};

function randomRoulette() {

  document.getElementById("roulette").style.display = "";

  var rand = Math.floor(2 * Math.random());
  document.getElementsByTagName("objective")[0].innerHTML = objectives_t[rand];
  document.getElementsByTagName("stratname")[0].innerHTML = stratnames_t[rand];

};

function main() {
  roulette.addEventListener("click", function() {
    randomRoulette();
  });
}

main();

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda