Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
¿Evitar que un generador repita opciones hasta que se agoten todas las opciones?

Siento que debería comenzar esto diciendo que ahora realmente estoy aprendiendo cómo incorporar cualquier cosa en JavaScript, así que explique las cosas y las respuestas en un nivel rudimentario.

Estoy tratando de averiguar cómo hacer que este script NO REPITA una opción hasta que TODAS las opciones se hayan agotado al menos una vez. Este es un problema común con Math.random por lo que veo, pero no tengo idea de cómo incorporar una solución para que no se repita.

 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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!