simplifyPath = (path, slash = '/', stack = []) => {    
    const paths = path.split(slash).filter(Boolean);

    for (const _path of paths) traversePath(_path, stack);

    return `${slash}${stack.join(slash)}`;
}
Stack
Time O(N) | Space O(N)
https://leetcode.com/problems/simplify-path
@param {string} path
@return {string}