+ 5
String to number
How can i turn a string into the result of a calculation. For example:"4*6" into 24 . Note ive tried parseInt(); Number() and parseFloat();
3 Answers
+ 8
var expression = "4*6";
Bad: eval(expression);
Not bad: (new Function("return "+expression))();
Pro: https://www.sololearn.com/learn/704/?ref=app
+ 5
Thank you
+ 4
Try eval()