I have an object list to store indexes just like that:
const initialIndexes = {
0: [0,1,2],
1: [0,1]
}
At this point I have a highlightedResultIndex
variable. It gives an index like this:
highlightedResultIndex = 0 - case 1
highlightedResultIndex = 4 - case 2
highlightedResultIndex = 2 - case 3
...
And I finally try to get the following results by highlightedResultIndex
For the case 1:
result = {
0: 0, // index from initialIndexes
1: -1
}
For the case 2:
result = {
0: -1,
1: 1 // index from initialIndexes
}
For the case 3:
result = {
0: 2 // index from initialIndexes
1: -1
}
Maybe there is an easy method or there may be a certain algorithm for this, but I didn’t know how to research it so I wanted to write it here. I would be glad if you help.