by olamide203 · 4y ago · 0 comments
Eg.
const a = 3;
const b = 2;
const expression = new Expression(`${a}*${b}(6/3(5--2))`);
const result = expression.evaluate();
document.getElementById("app").innerHTML = `a*b( 6 / 3( 5 - - 2 ) )= ${result}`;
Edit: formating const a = 2;
const b = 6;
const c = 3
const expression = new Expression('a \ b * c')
const result = expression.scope({a, b, c}).evaluate();
document.getElementById("app").innerHTML `${a} \ ${b} *
${c}= ${result}`I was trying to change the expression, but I need to change it twice. At the top where `expression` is defined and at the bottom to show it in the html. Is it possible to "see" what is inside an Expression object?