Yeah, I got kind of lost, too. The thing that threw me off were "trs[] =" and "tables[] =". The = sign is for assignment, not adding or appending. Each "trs[] =" is re-assigning the whole variable each time, overwriting anything that was already there (if I'm not mistaken).
But building tables with functions is more difficult for me in general. That may be because I learned HTML tables first.

