I have a multidimensional array of bools, with each element set to true:
var boolarray= $.extend(true, [], board);
board is a 3x3 multidimensional array of strings. boolarray is simply a deep copy of this.
for (var i=0; i < boolarray.length; i++) {
boolarray[i]
for (var j=0; j < boolarray[i].length; j++) {
boolarray[i][j] = true;
};
};
This gives me:
boolarray = [true,true,true,true,true,true,true,true,true]
I want to check if all elements are true and return if this is the case. However my method below does not work.
if (boolarray == true)
{
console.log("all elements in boolarray are true, return true ")
return true;
}
else
{
console.log("not all elements in boolarray are true, return false")
return false;
}
Any ideas of how I should check if boolarray is all true?
boolarray[i]
(immediately after the for loop's opening{
) doesn't do anything. – nnnnnn Apr 10 '12 at 22:17