我想要做类似以下的事情:
我看到的是:
你有没有关于如何修复它的想法?:)
function simpleOperations(operation) {
let myFanction = new Function('a', 'b', 'a ' + operation + ' b');
return myFanction
}
let sum = simpleOperations("+")
let multiplicate = simpleOperations("*")
console.log("your sum is: " + sum(3,7));
console.log("your product is: " + multiplicate(3,7));
而不是得到:
your sum is: 10
your product is: 21
我看到的是:
your sum is: undefined
your product is: undefined
你有没有关于如何修复它的想法?:)
return
。 - ASDFGerte