The use of eval() poses a security risk when used to evaluate user submitted text, so it's generally best avoided.
It's not an issue in your calculator (because there is no user text input), but it's just something to bear in mind for when you start working on larger project. Using eval() to parse data received from a text input field could enable a user to execute unauthorised JavaScript.
Instead of using eval() to calculate the sum of the tempCalc string, a safer approach would be to initialise tempCalc as an empty array and .push() numbers/operators to it as the user presses them.
// you can initialise tempCalc as an empty array on line 5
let tempCalc = [];
Turning the contents of this array into a single calculation would be a separate challenge, but if you get stuck, there's a suggested solution on this thread.
The use of eval() poses a security risk when used to evaluate user submitted text, so it's generally best avoided.
It's not an issue in your calculator (because there is no user text input), but it's just something to bear in mind for when you start working on larger project. Using eval() to parse data received from a text input field could enable a user to execute unauthorised JavaScript.
Instead of using eval() to calculate the sum of the
tempCalcstring, a safer approach would be to initialisetempCalcas an empty array and.push()numbers/operators to it as the user presses them.Turning the contents of this array into a single calculation would be a separate challenge, but if you get stuck, there's a suggested solution on this thread.