Check out example codes for "get index filter swift". It will help you in understanding the concepts better.
Code Example 1
let items: [String] = ["A", "B", "A", "C", "A", "D"]
print(items.enumerated().filter({ $0.element == "A" }).map({ $0.offset })) // -> [0, 2, 4]
Learn ReactJs, React Native from akashmittal.com