I know this is going to be pretty basic, and will probably get down voted on this but I am kinda lost at the moment.
I have an array of objects
let data = [
{id:1, Name: "Abe", RowNumber: 1 },
{id:2, Name: "Bob", RowNumber: 2 },
{id:3, Name: "Clair", RowNumber: 3 },
{id:4, Name: "Don", RowNumber: 3.0 },
{id:5, Name: "Edna", RowNumber: 3.1 },
{id:6, Name: "Frank", RowNumber: 3.2 },
{id:7, Name: "Gabe", RowNumber: 4 },
{id:8, Name: "Helen", RowNumber: 5 },
{id:9, Name: "Isabelle", RowNumber: 6 },
{id:10, Name: "Jane", RowNumber: 7 },
{id:11, Name: "Ken", RowNumber: 8 },
];
and I am trying to loop through them going backward and not forward, I have come up with this
for(let i = data.length; i != 0; i--){
console.log(data[i].Name);
}
and that is not working, I get an error about Name being undefined.
Can someone tell me where I am going wrong
["a", "b", "c"], it has indexes0,1, and2. But it has length3- if you takearray[array.length], you'd getundefined. You start your iteration atdata.length, which doesn't exist as an index.for(let i = data.length - 1; i >= 0; i--){ console.log(data[i].Name); }@HereticMonkeymentioned stackoverflow.com/questions/55520074/…)