DEV Community

kodekite
kodekite

Posted on

How to implement build in function .eval() with recursive function

Hei Coders,

I have a string "1+1", with javascript build in function eval() i can do eval("1+1") so the return value will be 2

But how about if i want to implement this concept to recursive function in javascript?

function evaluate(str) {

}

evaluate("1+1");
evaluate("1-1");
evaluate("1*1");
evaluate("1/1");

What i've tried…

Top comments (0)