I think the problem for you is coming from how you're attempting to push cells to defs. When you replace defs.push(cells)
on line 36 with defs = [...defs, cells]
it allows the columns and rows to be created properly. Then for some reason you're setting xmlns through a variable... this is the main thing preventing anything from showing up. There is no reason to use a variable to set xmlns, pretty sure it's preventing the SVG from being created properly when done this way and you don't actually need xmlns for inline SVGs, so you can trash that and all works well as shown here.
However, unless you're planning on using the empty space inside the 1000 x 1000 SVG area then I'd advise you to cut it down to 800 x 800 so the squares fit into the overall dimensions better.