My first array is for English words and my second array contains Spanish words. When the user enters a word in English from array1 the output will be the IndexOf array2. Instead of displaying the IndexOf array2 "1" how can I print the String in array 2.For example, I enter the word "cat" in the text field and click on "translate button" it will print out "0" index of array2. How can I print the word "gato" instead of 0?
var array1: [String] = ["cat", "dog", "lion"]
var array2: [String] = ["gato", "perro", "lion"]
for transIndex in array1.indices {
if array1[transIndex] == emptyString!.lowercaseString {
translatedWord.text = "\(transIndex)"
//print("transIndex is \(array1)")
return
}
}
translatedWord.text = "\(array2[transIndex])"