pull out separate 'checkSquare' function; use console.assert