From e863475b2d60687ef3dd9c29f99a9b8bdb261211 Mon Sep 17 00:00:00 2001 From: kevinnls Date: Mon, 26 Aug 2024 12:16:47 +0530 Subject: [PATCH] debugging statements that i needn't remove --- main.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.mjs b/main.mjs index 18d0717..f89b8a6 100644 --- a/main.mjs +++ b/main.mjs @@ -1,4 +1,7 @@ import { argv } from 'node:process'; +import { env } from 'node:process'; + +const DEBUG = Boolean(env.DEBUG); const grades = [ { @@ -31,13 +34,13 @@ function getGrade(mark){ if (typeof(mark) != 'number') for (let i=0;i<=grades.length-1;i++){ const {max} = grades[i] - console.log({i,max}) + printdebug({i,max}) if (max > mark) continue for (let j=i;j>0;j--) { const {min,grade} = grades[j] - console.log({j,min}) + printdebug({j,min}) if (mark < min) continue return grade } @@ -50,3 +53,9 @@ function getGrade(mark){ const grade = getGrade(argv[2]) console.log(grade) + +function printdebug(text) { + if (DEBUG) { + console.error('DEBUG:',text) + } +}