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

188
Vistas
Check a cookie and disable some code with it

Excuse the bad naming of this question, i didnt know what to name it. I am basically doing this math game website. The website asks you a math question and you answer in an input box below. It creates a random number from 1 to 3, decides from multiplication, addition or substraction depending on which number it picked. On another page the user can enable or disable what ecuations they want, for example if they disable multiplication it will update a cookie and it will no longer show the user multiplication questions. But the problem is that i have only come as far as setting the cookie. Ive tried many things but non of them worked. So i dont know what to do know. I would appreciate a little bit of criticism as getting things wrong is the only time you have a chance to get things right.

if (this.value == answer) {
   if(answered >= howManyQuestions + 1){
       stop();
       stopTimer();
      }
      generate();
      document.getElementById('inputAnswer').value = '';
      answered++;
    }
}


function generate() {
  document.getElementById('questionTrack').innerHTML = answered + '/' + howManyQuestions

  switch(Math.floor(Math.random() * 3) + 1) {
    case 1:
        elementOne = Math.floor(Math.random() * 50) + 1;
        elementTwo = Math.floor(Math.random() * elementOne) + 1;
        document.getElementById('question').innerHTML = elementOne.toString() + ' + ' + elementTwo.toString();
        answer = elementOne + elementTwo;
        break;
    case 2:
        elementOne = Math.floor(Math.random() * 50) + 1;
        elementTwo = Math.floor(Math.random() * elementOne) + 1;
        document.getElementById('question').innerHTML = elementOne.toString() + ' - ' + elementTwo.toString();
        answer = elementOne - elementTwo;
        break;
    case 3:
        elementOne = Math.floor(Math.random() * 10) + 1;
        elementTwo = Math.floor(Math.random() * 10) + 1;
        document.getElementById('question').innerHTML = elementOne.toString() + ' x ' + elementTwo.toString();
        answer = elementOne * elementTwo;
        break; 
    }
}```
about 4 years ago · Santiago Trujillo
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