Reputation: 186
var linkArray = [
['boothsizeDiv_link', false],
['furnishingsprovidedDiv_link', false],
['electricalDiv_link', false],
['rentalfurnishingsDiv_link', false],
['gesgraphicsDiv_link', false],
['geslaborDiv_link', false],
['contractorDiv_link', false],
['carpetingDiv_link', false],
['boothlightingDiv_link', false],
['javitsDiv_link', false],
['boothsealDiv_link', false],
['mannequinsDiv_link', false],
['calcDiv_link', false]
];
How can i loop through this array to get all 'false' values from that array?
Upvotes: 2
Views: 3512
Reputation: 5094
Judging by the variable name, the string values and the structure of your array, it might be a better approach to use object instead of array:
var linkObject = {
boothsizeDiv_link: false,
furnishingsprovidedDiv_link: false,
electricalDiv_link: false,
rentalfurnishingsDiv_link: false,
gesgraphicsDiv_link: false,
geslaborDiv_link: false,
contractorDiv_link: false,
carpetingDiv_link: false,
boothlightingDiv_link: false,
javitsDiv_link: false,
boothsealDiv_link: false,
mannequinsDiv_link: false,
calcDiv_link: false
};
Now you can get the array of the boolean values like this:
var ret = [];
for (var propertyName in linkObject) {
ret.push(linkObject[propertyName]);
}
But you can also get to a specific value like this:
linkObject['boothsizeDiv_link']
which yields false
.
Upvotes: 0
Reputation: 48415
If you just want a list of boolean values, the you can use this:
var falseValues = [];//this will be your list of false values
for(var i = 0; i < linkArray.length; i++){
var link = linkArray[i];
//test the value at array index 1 (i.e. the boolean part)
if(!link[1]){
falseValues.push(link[1]);//add the false to the list
}
}
Upvotes: 0
Reputation: 1716
use a loop
for (var i=0;i<linkArray.length;i++)
{
document.write(linkArray[i][1] + "<br>");
}
Upvotes: 3