lua push to aray

  1. Create an empty array by using the following code:
myArray = {}
  1. Add elements to the array using the following syntax:
myArray[1] = "apple"
myArray[2] = "banana"
myArray[3] = "orange"
  1. Access the elements of the array using the following code:
print(myArray[1]) -- Outputs: apple
print(myArray[2]) -- Outputs: banana
print(myArray[3]) -- Outputs: orange
  1. Iterate through the elements of the array using a loop, like this:
for i = 1, #myArray do
    print(myArray[i])
end