We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02131ee commit 81133d6Copy full SHA for 81133d6
1 file changed
web-app/js/projects/calculator.js
@@ -140,7 +140,7 @@ function initCalculator() {
140
function safeEval(expr) {
141
try {
142
if (!expr) return "";
143
- let result = eval(format(expr));
+ let result = Function('"use strict"; return (' + format(expr) + ')')();
144
if (result === undefined) return "";
145
if (isNaN(result)) return "Error";
146
return String(result);
@@ -170,7 +170,7 @@ function initCalculator() {
170
171
172
function clearIfFinished() {
173
- if (expression === "Error" || expression === "NaN") {
+ if (expression === "Error" || expression === "NaN" || expression === "Infinity" || expression === "-Infinity") {
174
expression = "";
175
}
176
0 commit comments