I am attempting to create two consecutive loops that will iterate through an array of customers and extract all the fruits from each customer's list. I initially tried using nested for loops, but this only provided me with the first fruit from each customer rather than every individual fruit in the entire array.
var customers = [{
"Name" : "John",
"Items" :[
{"Fruits" : "Apple"},{"Fruits" : "Orange"}]
},{
"Name" : "Sam",
"Items" :[
{"Fruits" : "Pear"},{"Fruits" : "Nuts"}]
},{
"Name" : "Eric",
"Items" :[
{"Fruits" : "Banana"},{"Fruits" : "Raisins"}]
}];
for(i=0; i<=customers.length; i++){
for(a=0; a<=customers[i]["Items"].length; a++){
alert(customers[i]["Items"][a]);
}
}