I need to calculate the difference `income` `total` between last two months (`_id`).

`{income[1]?.total}` always get me a fixed number: `900`.

How to calculate the `total` difference between last two elements?

Note: `res.data` already sorted by `_id`.

```
const [income, setIncome] = useState([]);
  const [perc, setPerc] = useState(0);
  useEffect(() => {
    const getIncome = async () => {
      try {
        const res = await userRequest.get("orders/income");
        const sort = res.data.sort((x, y) => x._id - y._id)
        setIncome(sort);
        setPerc((res.data[1].total * 100) / res.data[0].total - 100);
        console.log(sort);
      } catch {}
    };
    getIncome();
  }, []);

return(
  <div>{income[1]?.total} $</div>
)

```

this is my console.dev:

```
0: {_id: 6, total: 448}
1: {_id: 7, total: 900}
2: {_id: 8, total: 100}
3: {_id: 9, total: 700}
4: {_id: 10, total: 990}
5: {_id: 11, total: 20}
6: {_id: 12, total: 20}

```