Creating an array of arrays filled with 'false'

I am trying to create an array of arrays which are all filled with false in JavaScript. However, I keep getting this error:

Uncaught TypeError: Cannot read property 'push' of undefined

My current code is this:

var fieldFilled = [];

for (var i = 0; i < 10; i++) {
    fieldFilled.push([]);
            
    for (var j = 0; j < 10; j++) {
        fieldFilled[j].push(false);
    }
}

I don’t understand this error because it seems like fieldFilled is defined.

Thank you for your help.

34 thoughts on “Creating an array of arrays filled with 'false'”

  1. Do you have a spam issue on this site; I also am a
    blogger, and I was wondering your situation; we have developed some nice procedures and we are looking to exchange techniques with
    others, please shoot me an email if interested.

    Reply
  2. Today, I went to the beach front with my children. I
    found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell
    to her ear and screamed. There was a hermit crab inside and it pinched her
    ear. She never wants to go back! LoL I know this is
    completely off topic but I had to tell someone!

    Reply
  3. I do not know whether it’s just me or if perhaps everyone else experiencing problems with
    your blog. It seems like some of the text in your content are running off the screen. Can someone else please comment and let me know if this is happening to them as well?
    This could be a issue with my web browser because I’ve had this
    happen before. Cheers

    Reply
  4. I think what you typed was actually very reasonable.

    But, what about this? suppose you typed a catchier title?
    I am not suggesting your content isn’t solid, however
    suppose you added a title that makes people
    desire more? I mean Creating an array of arrays filled
    with 'false' – JavaScript Help is a little vanilla.
    You could peek at Yahoo’s front page and watch how they create article titles to get viewers to open the links.
    You might add a related video or a related pic or two to grab readers excited about what you’ve got
    to say. Just my opinion, it might bring your blog a little livelier.

    Reply

Leave a Comment