index.tsx520 chars19 linesThis code defines a function getIndexes that takes an array and a current index, and returns an object with the previous, current and next indexes based on the currentIndex.
The incrementIndex and decrementIndex functions take an array and a currentIndex, and call getIndexes to retrieve the next or previous index respectively.
Note that the incrementIndex function uses a modulo operation to cycle back to the first element of the array once the last element is reached, while the decrementIndex function uses modular arithmetic to cycle back to the last element of the array once the first element is reached.
gistlibby LogSnag