Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda