Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:38:41+00:00 2026-06-16T16:38:41+00:00

I am creating a whack-a-mole style educational game for children where a question is

  • 0

I am creating a “whack-a-mole” style educational game for children where a question is given and they have to click on the right appearing number. For example when a sum like “2+2” is given the child must wait for a “4” to appear and click it. The question changes every time the correct answer is hit, but the problem is when the new question appears there is no right answer and every number you click adds to the wrong score. Can someone tell me why this keeps happening.

Here is the cases for the sums..

function correctlabels() {
    switch (Math.ceil(Math.random() * 9)) {
        case 1:
            check = sum1;
            $('#target').html('0 + 1 = ?');
            break;
        case 2:
            check = sum2;
            $('#target').html('1 + 1 = ?');
            break;
        case 3:
            check = sum3;
            $('#target').html('2 + 1 = ?');
            break;
        case 4:
            check = sum4;
            $('#target').html('2 + 2 = ?');
            break;
        case 5:
            check = sum5;
            $('#target').html('2 + 3 = ?');
            break;
        case 6:
            check = sum6;
            $('#target').html('3 + 3 = ?');
            break;
        case 7:
            check = sum7;
            $('#target').html('2 + 5 = ?');
            break;
        case 8:
            check = sum8;
            $('#target').html('2 + 6 = ?');
            break;
        case 9:
            check = sum9;
            $('#target').html('2 + 5 = ?');
            break;
    }

Here is a fiddle to show what I mean.. http://jsfiddle.net/pUwKb/8/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:38:42+00:00Added an answer on June 16, 2026 at 4:38 pm

    I think it’s because you never re-add ‘right’ classes.
    Try changing this:

        $('.character').each(function (index, character) {
            if (!check(parseInt(this.getAttribute("value")))) {
                $(this).addClass("wrong");
                $(this).removeClass("right");
            }
        });
    

    to this:

        $('.character').each(function (index, character) {
            if (!check(parseInt(this.getAttribute("value")))) {
                $(this).addClass("wrong");
                $(this).removeClass("right");
            } else {
                $(this).addClass("right");
                $(this).removeClass("wrong");
            }
        });
    

    Nice game btw 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a whack-a-mole style game for primary school children where they have
I am creating a new whack-a-mole style game where the children have to hit
I am creating a new whack-a-mole style game where the children have to hit
I am creating a whack-a-mole style game where a sum is given and numbers
I am creating a whack-a-mole style game where a sum is given and numbers
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Creating a simple RPG game, first time using XNA. Trying to get my character
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
Creating shell output for a game, but don't want the window to scroll with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.