Answer the question
In order to leave comments, you need to log in
How to replace eval in my code?
Is it possible to do something differently instead of putting all the code in eval?
arg1 = 'x'
arg2 = 'y'
function multiply(arg1, arg2){
let ans = []
for (let i = 0; i < arr.length; i++) {
eval(`ans[i] = arr[i].${arg1} * arr[i].${arg2}`)
}
return ans
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question