silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.18k stars 239 forks source link

.evaluate() method does not accept variables as argument #268

Closed dieegoalvareez closed 2 years ago

dieegoalvareez commented 2 years ago

I want to pass key from a variable: if (expr){ const parser = new Parser(); let math_expr = parser.parse(expr); y = "y1" console.log(y) //y1 console.log(typeof y) //string console.log(math_expr.evaluate({ y : 3 })) }

what evaluate(token,expr,value) recives: console.log(value, expr) --> Output: { y: 3 }, Instruction { type: 'IVAR', value: 'y1' } and should receive { y1: 3 }, Instruction { type: 'IVAR', value: 'y1' }

regards,