Could someone tell me how can I make from regular text an if statement? Example:
let statement1 = "(5 < 10 < 15)"
let statement1 = createState(statement1); // output: true
let statement2 = "(50 < 100 < 150)"
let statement2 = createState(statement2); // output: true
let statement3 = "(5 > 10 > 15)"
let statement3 = createState(statement3); // output: false
let statement4 = "(50 > 100 < 150)"
let statement4 = createState(statement4); // output: false
function createState() {
// code here...
}
I found this answer: If statement from string statement, but it is using eval and I don't want to use already built functions in JS P.S: the performance of the site will be slow if I'll use already built functions in JS