I have a string that is building a condition, it could read:
"true || false" or "false || false" or "true && false" etc..
I want to simply check if it passes or not. Any suggestions?
I have a string that is building a condition, it could read:
"true || false" or "false || false" or "true && false" etc..
I want to simply check if it passes or not. Any suggestions?
Why don't you just use a boolean instead of assembling the string? I'm assuming you're running something like:
str += ' && ' + !!(Find some value)
Instead, track with a boolean:
trackingBool = trackingBool && !!(Find some value)
This way you avoid using a string as a boolean (an antipattern if I've ever seen one) and others reading your code have a better idea of what's going on.
eval seems to be what I am looking for even though Ingo said not to use it ;)