i have a basic array of object coming from an api something like:
[
{date:'2020-10-02, number: 400},
{date:'2020-10-01, number: 200},
... ]
And so on, actually i don't know how many items are in the array, but i need to get the last two
i corerctly download and store the data
my
console.log(data.lenght);
Shows the correct lenght of array (222 at the moment of writing);
As i said i need to show the latest date, the actual number and the difference with previous date; if i manually set the numbers it works as expected:
<Text>
{data[222].date} - {data[222].number}
Variation {data[222].number - data[221].number}
</Text>
but if i try to use the length of data as the index it give me an error: undefined is not an object (evaluating 'data[len].date'
len=data.length
...
<Text>
{len}
{data[len].date} - {data[len].number}
Variation {data[len].number - data[len-1].number}
</Text>
len is printed correctly, i also tried to place it in {} double {{}} and other things like that i was wondering how can i access object using a "calculated" index