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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:35:52+00:00 2026-06-08T17:35:52+00:00

I have a list of 3 letter words that dynamically generate a grid. The

  • 0

I have a list of 3 letter words that dynamically generate a grid.

The problem is I need a 6×6 grid, and if there is not enough words in the list to facilitate a 6×6 (12 words) then it won’t be the size needed, and only be a grid as big as the words in it.

How can I make it so it always produces a 6×6 grid, randomly generates positions for the words and fills the gaps with empty cells?

var listOfWords = {};

var ul = document.getElementById("wordlist");

var i;
for(i = 0; i < ul.children.length; ++i){
listOfWords[ul.children[i].getAttribute("data-word")] = {
     "pic" : ul.children[i].getAttribute("data-pic"),
     "audio" : ul.children[i].getAttribute("data-audio")
};
}

 console.log(listOfWords);
 var shuffledWords = Object.keys(listOfWords).slice(0).sort(function() {
 return 0.5 - Math.random();
 }).slice(0, 12);
 var guesses = {}
console.log(shuffledWords);
var tbl = document.createElement('table');
tbl.className = 'tablestyle';
var wordsPerRow = 2;

for (var i = 0; i < Object.keys(shuffledWords).length - 1; i += wordsPerRow) {
var row = document.createElement('tr');

for (var j = i; j < i + wordsPerRow; ++j) {
    var word = shuffledWords[j];
    guesses[word] = [];

    for (var k = 0; k < word.length; ++k) {
        var cell = document.createElement('td');


        $(cell).addClass('drop').attr('data-word', word);
        cell.textContent = word[k];
        // IF FIREFOX USE cell.textContent = word[j]; INSTEAD
        row.appendChild(cell);
    }
}
tbl.appendChild(row);
}

document.body.appendChild(tbl);

I have tried this, but cannot get it to work….

while(listOfWords.length < 12)
listOfWords.push("   ");
  • 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-08T17:35:53+00:00Added an answer on June 8, 2026 at 5:35 pm

    Did you try creating the table with the required size before, and then putting the word to a random td and tr?

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

Sidebar

Related Questions

I have list of screen names that can be filtered by letter. The Issue
I have a huge word list of over 280.000+ words that is loaded from
I have a code aaabbbcccdddeee that I split up into 3 letter words (such
i have list of rows that user select and i want to delete them,
i have list of images and on mouse over there is option box shows
I have list of words. I type in a word misspelled. Can I query
I have a dynamically generated list of students. I want the users to capture
I have a list of a hundred words or so and a list of
So I have a list of words `wordList = list().' Right now, I am
I have an UITableView, and in it I have different sections - words that

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.