Jump to content

Multidimensional array


mrbean

Recommended Posts

Why doesn't this work?

 

var candy = new Array(new Array());
for (var i = 0; i < 10; i++) {
    candy[i][i] = "Sweet!";
  }

 

The error that I get from chrome is:

Uncaught TypeError: Cannot set property '0' of undefined

 

I want to make an multidimensional array in an loop without knowing how long it can be.

Link to comment
https://forums.phpfreaks.com/topic/266997-multidimensional-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.