I have an array of objects. I need to get the object type (\"shape\" in this example) of the last object, remove it, and then find the index of the previous object in the ar
You can transform your array to an array boolean type and get the last true index.
boolean
true
const lastIndex = fruits.map(fruit => fruit.shape === currentShape).lastIndexOf(true);