I cant get this loop to work in my script
===

I basically want this loop to produce random spaces in a grid I am developing, but cannot get it to work in my script.

I want this loop to push the random spaces

        for(var x = 0; x < 6; x++)
    {
        var rand = Math.floor(Math.random() * (listOfWords.length+1));
        chosenWords.push(listOfWords[rand]);
         If(chosenWords.length < 12){
                    chosenWords.push(“  ”);   
          }

    }

In this script, so the grid will generate 6x6, half words half spaces. Thanks!

    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, 6);
    var guesses = {}
    console.log(shuffledWords);
    var tbl = document.createElement('table');
    tbl.className = 'tablestyle';
    var wordsPerRow = 2;

    for(var x = 0; x < 6; x++)
    {
        var rand = Math.floor(Math.random() * (listOfWords.length+1));
        chosenWords.push(listOfWords[rand]);
          If(chosenWords.length < 12){
                    chosenWords.push(“  ”);   
          }

    }

    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];
            
                row.appendChild(cell);
            }
        }
        tbl.appendChild(row);
    }

    document.body.appendChild(tbl);

