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

187
Visualizações
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 à 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