Lesya,
Вариант...
function balance(a) {
var b;
b = a;
a = a.replace(/(\u0028)[^\u0028]*?$/, function (a) {
return a = a.replace(/\u0028(.*?)\u0029/, function (a) {
return eval(a)
})
});
b != a && (a = balance(a));
return !/[\u0028\u0029]/.test(a) ? eval(a) : !1
};
alert(balance("(((1+2)+3)*10-(3-1))/10")+"\n"+balance("(((1+2)+3)*10)-(3-1))/10"))