Hopefully this is pretty simple.. example below:
var myArray = [{color:"red",name:"1"},{color:"blue",name:"2"},{color:"green",name:"3"},{color:orange,name:4},{color:"yellow",name:"5"}];
for (i=0; i<myArray.length; i++){
if (myArray[i].color == "red"){
console.log ("yep");
}
}
This of course works fine, but what if I want to exchange "color" with a variable:
var myArray = [{color:"red",name:"1"},{color:"blue",name:"2"},{color:"green",name:"3"},{color:orange,name:4},{color:"yellow",name:"5"}];
var c = "color";
for (i=0; i<myArray.length; i++){
if (myArray[i].c == "red"){
console.log ("yep");
}
}