I have an array called customers, each customer has a name, id, account number, address and account information:
var customers = [
{
"name": "John Doe",
"id": 1205,
"accountNumber": 187456,
"address": {
"houseNumber": 12,
"streetName": "made up street",
"postCode": "WE1 234",
"area": "Birmingham"
},
"hasCurrentAccount": true,
"hasLoan": false,
"hasMortgage": true
},
{
"name": "Jane Doe",
"id": 1304,
"accountNumber": 123456,
"address": {
"houseNumber": 420,
"streetName": "The Street",
"postCode": "DE3 456",
"area": "Wolverhampton"
},
"hasCurrentAccount": false,
"hasLoan": true,
"hasMortgage": false
}
];
for now I'm trying to iterate through this array retrieve the name and id and print it to the console:
var info = customers;
for (var i in info)
{
var id = info.id;
var name = info.name;
console.log('Here are your current customers' + id + ' ' + name);
}
but I just get
Here are your current customers undefined undefined
I've tried different methods and I just can't seem to get it working. Can anyone help?