Hacker News new | ask | show | jobs
by olamide203 1397 days ago
Nice tip, i'm planning to add an identifier node class so that you can pass a scope with the values to be used during evaluation. Eg.

   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}`
2 comments

[Add an empty line and then two spaces before each line to trigger the "code" mode.]
Very welcome solution. String interpolation makes it possible, but it's bad DX.
yeah having to type ${} everywhere makes the code a little bit messy.