Check out example codes for "How to find index of list item in Swift?". It will help you in understanding the concepts better.

Code Example 1

let arr = ["a","b","c","a"]

let indexOfA = arr.firstIndex(of: "a") // 0
let indexOfB = arr.lastIndex(of: "a") // 3

Learn ReactJs, React Native from akashmittal.com