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

194
Views
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
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!