Loop through Table

local newsItem = {
    {
        newsTitle = "",
        newsDescription = "",
        imageId = 0
    }, 
    {
        newsTitle = "",
        newsDescription = "",
        imageId = 0
    }
}

How can I loop through this table and print newsTitle for each table in the table (if that makes sense)?

1 Like

This is very easy to achieve.

If you wanted to print everything in the table you’d wanna do a ‘in pairs()’ loop, Like this:

for _,NewItemTable in pairs(newsItem) do
	print(NewItemTable.newsTitle)
	print(NewItemTable.newsDescription)
	print(NewItemTable.imageId)
end
1 Like