JavaScript creating game grid properly