numIslands = function(grid, connectedComponents = 0) {
    const [ rows, cols ] = [ grid.length, grid[0].length ]

    for (let row = 0; row < rows; row++) {/* Time O(ROWS) */
        for (let col = 0; col < cols; col++) {/* Time O(COLS) */
            const isIsland = grid[row][col] === '1';
            if (isIsland) connectedComponents++;

            bfs(grid, rows, cols, new Queue([ [ row, col ] ]));/* Space O(MIN(ROWS,COLS)) */
        }
    }

    return connectedComponents
 }
https://leetcode.com/problems/number-of-islands/
Time O(ROWS * COLS) | Space O(MIN(ROWS,COLS))
@param {character[][]} grid
@return {number}