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

  • Home
  • SEARCH
  • 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 8536339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:38:23+00:00 2026-06-11T10:38:23+00:00

In my spelling game there are different size words from 3-6. Once a certain

  • 0

In my spelling game there are different size words from 3-6. Once a certain amount of words are completed in the grid the rest of the grid fades away. I want it to add up all the word size varieties rather than just taking one in to consideration. For example I have it at the moment to fadeOut once two words are completed. The problem is it only fades when two, three letter words are complete or two four letter words are complete etc.

var completeLetters = $('.wordglow2').length;
var threeLetter = (completeLetters / 3);
var fourLetter = (completeLetters / 4);
var fiveLetter = (completeLetters / 5);
var sixLetter = (completeLetters / 6);


if (threeLetter == 2) {
    $('table').fadeOut(2000);
}
if (fourLetter == 2) {
    $('table').fadeOut(2000);
}
if (fiveLetter == 2) {
    $('table').fadeOut(2000);
}
if (sixLetter== 2) {
    $('table').fadeOut(2000);
}

Is there not a way of having a variable that combines all the words and then creating an if statement for that?

  • 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-11T10:38:25+00:00Added an answer on June 11, 2026 at 10:38 am

    Firstly – I would advise that you are doing this the wrong way – you are determining game state from the HTML/CSS representation of the game. I would recommend that you create an object which represents the game state and then use this object to determine the manipulations you need to make to the HTML/CSS representation. This will also make doing what you are trying to do here much easier.

    For example you may end up being able to say something like…

    if (gamestate.wordscomplete == 3) {//fade board//}
    

    …which is a lot more pleasant than digging through the HTML. But I digress…

    Ok so the class wordglow2 gets added to a letter when it is correct. Each <tr> in the grid can contain a word. So…

    function gamestate() {
      var words = []; //new array to store completed word counts
      var wordscompleted = 0; //overall word count
      //create an entry for 3,4,5, and 6 letter words
      for (var wc = 3; wc <=6 ; wc++) {words[wc] = 0;}
    
      $('table.tablestyle > tr').each( function(i,el) {
        // get the number of complete letters in this row
        var wordlength = $(el).find('.wordglow2').length; 
        if (wordlength >=3 && wordlength <= 6) { 
          // a completed word should not be outside of this range anyway
          words[wordlength]++; //increment the appropriate counter
          wordscompleted++; //increment overall counter
        }
      });
      //return a gamestate object 
      return { wordscompleted : wordscompleted , words : words };
    }; 
    

    The above function will look at each row in the game table and count the number of wordglow2 cells. If this is between 3 and 6 then an overall counter is incremented and also counter for each word length is incremented.

    It can be used as follows…

    var gs = gamestate();
    
    gs.wordscompleted //total words completed
    gs.words[3]       //total 3-letter words completed
    gs.words[4]       //total 4-letter words completed etc etc
    

    UPDATE

    http://jsfiddle.net/HZX6k/6/

    This fiddle just uses a global object to track the gamestate incrementing the count and the count for each of the 3,4,5,6 letter count words as it goes.

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

Sidebar

Related Questions

In my spelling game there is a grid that is populated with words. The
In my spelling game there is a grid populated with hidden words. The aim
In my spelling game there is a grid with words in to spell. The
In my spelling game there is a grid that is populated with words that
In my spelling game new words will be added all the time so there
In my spelling game, when a word is complete it fades away in the
Is there any way to check spelling for ALL the words that I type
In my drag and drop game there is a grid that is populated with
In my spelling game at the moment, the grid is designed for 3 letter
Is there anyway to create C# spelling checker without using Office library? I would

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.