I am trying to use a forEach loop to loop through an array of JSON objects so that I can print the values to the document.
const incomes = [
{
name: "Walter",
amount: 100,
recurring: true,
},
{
name: "Walter",
amount: 100,
recurring: true,
},
{
name: "Walter",
amount: 100,
recurring: true,
},
{
name: "Walter",
amount: 100,
recurring: true,
},
{
name: "Walter",
amount: 100,
recurring: true,
},
];
for (i = 0; i < incomes.length; i++) {
document.write(incomes.amount);
}
Above you can see the code I've been trying, but the issue is all that shows up on the document is "undefined undefined undefined undefined undefined".
Do you know why it is saying these values are undefined?
Many thanks!