Skip to content

Commit 81133d6

Browse files
author
Your Name
committed
fix: resolve calculator-operator-chaining
1 parent 02131ee commit 81133d6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

web-app/js/projects/calculator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function initCalculator() {
140140
function safeEval(expr) {
141141
try {
142142
if (!expr) return "";
143-
let result = eval(format(expr));
143+
let result = Function('"use strict"; return (' + format(expr) + ')')();
144144
if (result === undefined) return "";
145145
if (isNaN(result)) return "Error";
146146
return String(result);
@@ -170,7 +170,7 @@ function initCalculator() {
170170

171171

172172
function clearIfFinished() {
173-
if (expression === "Error" || expression === "NaN") {
173+
if (expression === "Error" || expression === "NaN" || expression === "Infinity" || expression === "-Infinity") {
174174
expression = "";
175175
}
176176
}

0 commit comments

Comments
 (0)