Is it possible to convert/wrap an array value into a if statement? For clarification, the statement I received from my code is always a string in an array, and I want to execute it in an if block. Right now, it does not do a comparison because it is a string. So how can I convert a string into a statement that will be compared?
let counter = 11;
let statement = ['counter > 10']; // array string received from other code (always a string)
if(statement[0]) {
// should be true
}
Result expected to be true, where the if statement is dynamically executed.