see if index is last in array js code example
Example: how to check the last item in an array javascript
const colors = ['red', 'yellow', 'green', 'blue']
const lastItem = colors[colors.length - 1]
console.log(lastItem)
const colors = ['red', 'yellow', 'green', 'blue']
const lastItem = colors[colors.length - 1]
console.log(lastItem)