How to check if 2 indexes are duplicates in an array

I wanted to know if it’s possible to tell if an ordered array has 2 of the same index such as:
image

When testing to see if it is possible using ipairs the bottom index in my array will always take priority over the first and replace it. As it doesn’t even exist anymore.
image

I know in the script itself will tell you “Table index 2 is a duplicate”, but I just wanted to see if it’s possible to do it this way (I intend to let people edit this script & trying to combat every possible scenario as a challenge). Otherwise I’ll make it a dictionary instead and sort an integer from there.

An ordered array (or even a dictionary) can never have two of the same indices. If it does, the old index is automatically overwritten by the new one

1 Like

Even with duplicate dictionary keys it still has the same outcome regardless. 1 thing overwriting another. Thought I might ask still.