FOR Loops

A For loop is used to iterate over a predefined set of numbers, iterate over the key and value pairs of a dictionary or the values of an array.

Note: The function, ForAllValues, is available for iterating of over all axes of a dataset.
for i = 1, 3 do
for j = 0, 9, 3 do
print("for loops add 1 to i and 3 to j during each iteration " .. i .. ' ' .. j)
end
end

myDict = {["bread"] = "brown", ["eggs"] = 12}
for key, val in pairs(myDict) do
print(key .. "  " .. val)
end

myArray = {1,1,2,3,5,8,13}
for key, val in pairs(myArray) do
print(key .. "  " .. val)
end