String to Math Calculation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

String to Math Calculation

I have a string "50+10-5*6" and I have to convert it to integer and do the calculation which will result in 30. Language: Javascript

8th Mar 2021, 4:52 AM
Khan ⭐
Khan ⭐ - avatar
2 Answers
+ 1
Then what should I use? Ryan Els
9th Mar 2021, 10:33 AM
Khan ⭐
Khan ⭐ - avatar
0
Khan ⭐ The use of eval is not good practice. It is known to produce unexpect results. A hackers dream function.
9th Mar 2021, 7:19 AM
Ryan Els
Ryan Els - avatar