Skip to content Skip to sidebar Skip to footer

Evaluate String As A Conditional Statement

I am working on a c++ web-based IDE for beginners where one of it's core function is to let the user know the evaluation result (true or false) of the conditional statement they ha

Solution 1:

You can use Eval like this:

var expression = $('.frag').eq(1).text();
var result = eval(expression);

However I generally do not recommend using eval because there is always a much better workaround.

if I get the bigger picture of your needs I would be able to provide a better solution.

Post a Comment for "Evaluate String As A Conditional Statement"