The first term is obvious: Just replace all dashes by opening parentheses. The second replaces all dashes by closing parentheses while dropping everything else.

    function dashesToParentheses(str) {
        return str.replace(/-/g, "(") + str.replace(/[^-]*-[^-]*/g, ")");
    }