[Algorithm] 14 week(4.11 ~ 4.17) 3/3


1614. Maximum Nesting Depth of the Parentheses

var maxDepth = function(s) {
    let depth = 0;
    const onlyBrakets = s.replace(/[^()]/g, "");

    let braketCount = 0;
    for (const braket of onlyBrakets) {
        if (braket === "(") {
            braketCount++;
        }
        else {
            depth = Math.max(braketCount, depth);
            braketCount--;
        }
    }
    return depth;    
};