mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
CODEBASE: Fix lint errors 2 (#1756)
This commit is contained in:
@@ -9,11 +9,11 @@ export function expr(args: (string | number | boolean)[]): void {
|
||||
|
||||
// Sanitize the math expression
|
||||
const sanitizedExpr = expr.replace(/[^-()\d/*+.%]/g, "");
|
||||
let result;
|
||||
let result: string;
|
||||
try {
|
||||
result = eval?.(sanitizedExpr);
|
||||
result = String(eval?.(sanitizedExpr));
|
||||
} catch (e) {
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}`);
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}. Error: ${e}.`);
|
||||
return;
|
||||
}
|
||||
Terminal.print(result);
|
||||
|
||||
Reference in New Issue
Block a user