Answers for "make valid string for eval()"

0

make valid string for eval()

// strip anything other than digits, (), -+/* and .
var str = "12/5*9+9.4*2".replace(/[^-()\d/*+.]/g, '');
alert(eval(str));
Posted by: Guest on July-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language