Sum units in a table.
Goal
Print 25 units and Nairobi as busiest.
local rows = {
{ city = "Nairobi", units = 12, shillings = 480 },
{ city = "Mombasa", units = 8, shillings = 320 },
{ city = "Kisumu", units = 5, shillings = 200 },
}
local units, shillings, busiest = 0, 0, rows[1]
for _, r in ipairs(rows) do
units = units + r.units
shillings = shillings + r.shillings
if r.units > busiest.units then busiest = r end
end
print("units", units)
print("shillings", shillings)
print("busiest", busiest.city)