I have a for loop that checks if a number is a factor of a number, then checks if that factor is prime, and then it adds it to an array. Depending on the original number, I wil
Using a simple solution you can make for loop reverse using Stride and -
func reverseArray(oldarray: [String]) -> [String] {
var newArray = [String]()
let len = oldarray.count
for i in stride(from: len - 1, through: 0, by: -1)
{ newArray.append(oldarray[i])
print(i)
}
return newArray
}
input : print(reverseArray(oldarray: ["World", "Hello"]))
output : ["Hello", "World"]