LauraNicole449 / calculator

https://calculator-theta-mauve-78.vercel.app
0 stars 1 forks source link

Refactor calculate function to use safer method for mathematical evaluation #4

Closed anibalalpizar closed 8 months ago

anibalalpizar commented 8 months ago

Description

This PR updates the implementation of the calculate function in calculator.js to improve security by avoiding the use of the eval function. Instead of eval, the Function function is now used to evaluate mathematical expressions more safely.

Changes made

Context

This change addresses security related to the use of eval. By making this change, we improved the robustness and security of the code, while maintaining the expected functionality of the calculator.

Functionality Check

Testing has been performed to ensure that calculator functionality is not adversely affected and that changing the calculate function works as expected.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval

image

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
calculator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 12, 2024 5:18am