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 8864147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:10:00+00:00 2026-06-14T16:10:00+00:00

EDIT** In a game I am creating I use the next question button to

  • 0

EDIT**

In a game I am creating I use the next question button to move onto other questions in the grid if the user is having trouble with the current one. At the moment I have had real problems with it as it keeps on crashing my program, and not giving any console errors. The last problem I had with it was that it said “too much recursion”. Since then I thought I had sorted the problem, but I have just done a few tests and it crashes every time.

This is the click event for the button…

//Next question click event
$('.next-question').bind("click", function() {
    $('td').removeClass('highlight-problem');
    shuffleEqually(listOfWords);
    shuffleEqually(nextWordIndexes);
    var rndWord = nextWordIndexes[Math.floor(Math.random())];
    var rndWord = nextWordIndexes[2];
    //Adds and removes nesesary classes
    $('td[data-word="' + listOfWords[rndWord].name + '"]').addClass('highlight-problem');
    $('td[data-word=' + word + ']').removeClass('wrong-letter').removeClass('wrong-word').removeClass('right-letter');
    var spellSpace = $('td[data-word="' + listOfWords[rndWord].name + '"]').hasClass('right-word');
    if (spellSpace) {
        $('.next-question').trigger('click');
    } else {
        $("#hintSound").attr('src', listOfWords[rndWord].audio);
        hintSound.play();
        $("#hintPic").attr('src', listOfWords[rndWord].pic);
        $('#hintPicTitle').attr('title', listOfWords[rndWord].hint);
    }
});

I think it may have something to do with the if statement, but have tried changing it to this..

if (spellSpace == false) {

    $("#hintSound").attr('src', listOfWords[rndWord].audio);
    hintSound.play();
    $("#hintPic").attr('src', listOfWords[rndWord].pic);
    $('#hintPicTitle').attr('title', listOfWords[rndWord].hint);
}

and it makes it even worse

ShuffleEqually:

//Shuffles words to randomize
shuffleEqually(nextWordIndexes);
var shuffledWords = [];
shuffledWords = chosenWords.sort(function () {
    return 0.5 - Math.random();
});

function shuffleEqually(a1, a2) {
    var arrays = [];
    if (typeof a1 === 'object' && a1.length > 0) {
        arrays.push(a1);
    }
    if (typeof a2 === 'object' && a2.length > 0) {
        arrays.push(a2);
    }
    var minLength = arrays[0].length;
    jQuery.each(arrays, function (i, a) {
        minLength = a.length < minLength ? a.length : minLength;
    });
    var randoms = [];
    for (i = 0; i < minLength; i++) {
        randoms.push(Math.random());
    }
    jQuery.each(arrays, function (i, a) {
        var i = minLength;
        while (i--) {
            var p = parseInt(randoms[i] * minLength);
            var t = a[i];
            a[i] = a[p];
            a[p] = t;
        }
    });
};

Hint sound:

var hintSound = $("#hintSound")[0];
  • 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-14T16:10:01+00:00Added an answer on June 14, 2026 at 4:10 pm

    Your issue is an infinite loop, plain and simple.

    $('.next-question').bind("click", function() {
    // binds click...
    ...
    
    
    if (spellSpace) {
        $('.next-question').trigger('click');
        // triggers click ON THE SAME ELEMENT COLLECTION (same selector)
    

    You want to refine this. I assume you want the trigger to work on the next question, so I suggest changing the second statement to:

     $(".next-question").eq(($(".next-question").index($(this)) + 1) % $(".next-question").length).trigger("click");
    

    You have a second infinite loop in shuffleEqually:

       jQuery.each(arrays, function (i, a) {
        var i = minLength;
        while (i--) {
            var p = parseInt(randoms[i] * minLength);
            var t = a[i];
            a[i] = a[p];
            a[p] = t;
        }
    

    Change the while condition to have a limiting value, or it will loop endlessly (as a decrement operation always succeeds).

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

Sidebar

Related Questions

I am creating a game in cocos2d-android. all the images i use in Sprite
EDIT** In my game I want my button to disable after one click but
I'm creating a simple JavaScript multiple choice game. Here is a sample question: p
I am creating a little game where you need to move troops on a
**EDIT* * I am currently creating a drag and drop spelling game where the
I'm creating a game with jQuery, and I want my character to move automatically
I'm currently in the process of creating a shared Edit/Create view for my game
I'm creating a grid based game in Java and I want to implement game
I'm creating a game where objects fall from the sky that the user has
I am creating a game where each player fills a 3x3 grid and they

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.