javascript dfs+map w/ comments
\nfunction findCircleNum(M) {\n    // visited set\n    const visited = new Set();\n    // friend circles count\n    let circles = 0;\n\t\n    // iterate thru ma
```\nfunction findCircleNum(M) {\n    // visited set\n    const visited = new Set();\n    // friend circles count\n    let circles = 0;\n\t\n    // iterate thru matrix\n    for (let i = 0; i < M.length; i++) {\n        // check if this friend has been visited before\n        if (!visited.has(i)) {\n            // start dfs for this friend\n            dfs(i);\n            // this is another friend circle\n            circles++;\n        }\n    }\n\t\n    return circles;\n\t\n    // helper method to do dfs traversal thru M\n    function dfs(i) {\n        // go thru this friend\'s friends\n        for (let j = 0; j < M.length; j++) {\n            // check if this is a friend, and not visited before\n            if (M[i][j] === 1 && !visited.has(j)) {\n                // add as visited\n                visited.add(j);\n                // call dfs\n                dfs(j);\n            }\n        }\n    }\n}\n```\n
['Depth-First Search', 'JavaScript']