编辑代码

//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
var reverseParentheses = function(s) {
    let length = s.length,
        sub = '',
        stack = []
    for(let char of s){
        if(char === '('){
            stack.push(sub)
            sub = ''
            continue
        }
        if(char === ')'){
            sub = stack.pop() + sub.split('').reverse().join('')
            continue
        }
        sub += char
    }
    
    return sub
};


console.log(reverseParentheses("(ed(et(oc))el)"))