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) + } +}