Comments suggested that a count is returned.
scan.ports returns an array of ports, not a count. A count can be
obtained via scan.ports.length