Use of eval in Javascript Calculator

Hey all,

I’ve been working through the Javascript calculator project and noticed the demo project uses the eval() function. I considered this myself but read that it is considered bad practice and can pose a security risk. Can someone help me understand why it was chosen for this project and when if at all it is appropriate?

Thanks!

The string being fed into the eval is being filtered and built internally, rather than by direct user manipulation. It made me cringe too, but this is a pretty safe use case.