问题很简单,但我还没有找到我想要的。基本示例:
const firstNumber = 5;
const secondNumber = 3;
let operator = "-";
const string = `${firstNumber} ${operator} ${secondNumber}`;
const unfortunatelyNaN = Number(string);
console.log(string, unfortunatelyNaN)
以上只是我的想法,但任何让我能够动态更改操作符的东西都可以。有任何想法吗?
相关分类