How do you find add the numbers together that are in one table?
Weird Example:
local t = {1, 4, 6, 9} print(t[i] + t[i])
The answer to this would be "20".
I have no clue on how to do that. Does anyone know how to add up all the numbers in a single table or arrangement?
local t = {1,4,6,9} -- table local total = 0 -- variable for the total for i,v in pairs(tab) do -- iterate through the table and add on to the total total = total + v end print(total)
I don't know if there is any other way to do this, as I am not very good with tables, but this works.