- Home /
Question by
MileSplit · Apr 14, 2013 at 05:27 PM ·
javascriptarraysloop
Assign Default For Large Array
Hello, As a part of my project I have a array like this myArray[100,100], it is a string array. I use it to set the text of cards. My problem is that in order for the cards to show, myArray must have a default value. I have tested this by saying,
myArray[1,1] = " ";
and then card 1,1 works.
My question is how would i assign " " to 10000 variables?! THANKS
Comment
Best Answer
Answer by ByteSheep · Apr 14, 2013 at 05:37 PM
You could do something like this:
var arrayLength = 1000;
var myArray = new Array ();
myArray.length = arrayLength;
for(var i = 0; i < myArray.length; i++)
{
myArray[i] = " ";
}
dang and I was hoping there's a possibility to give to all default value in 1 line. so I don't need to write this:
bool[] Hit = new bool[6] {true, true, true, true, true, true};
anyway +1 to both