DEV Community

Discussion on: How to make a Calculator (Working and Animated)

csirolli profile image
Christian Sirolli

One concern. I can type any JavaScript into the input element, click = and the calculator will run that JavaScript. This is because of the eval in the = button's onclick. Avoid using eval as much as possible, and prefer to validate the input instead. This makes it much more complicated, but avoids a security issue.