debugging statements that i needn't remove

This commit is contained in:
2024-08-26 12:16:47 +05:30
parent 47a565e7c0
commit e863475b2d

View File

@@ -1,4 +1,7 @@
import { argv } from 'node:process'; import { argv } from 'node:process';
import { env } from 'node:process';
const DEBUG = Boolean(env.DEBUG);
const grades = [ const grades = [
{ {
@@ -31,13 +34,13 @@ function getGrade(mark){
if (typeof(mark) != 'number') if (typeof(mark) != 'number')
for (let i=0;i<=grades.length-1;i++){ for (let i=0;i<=grades.length-1;i++){
const {max} = grades[i] const {max} = grades[i]
console.log({i,max}) printdebug({i,max})
if (max > mark) continue if (max > mark) continue
for (let j=i;j>0;j--) { for (let j=i;j>0;j--) {
const {min,grade} = grades[j] const {min,grade} = grades[j]
console.log({j,min}) printdebug({j,min})
if (mark < min) continue if (mark < min) continue
return grade return grade
} }
@@ -50,3 +53,9 @@ function getGrade(mark){
const grade = getGrade(argv[2]) const grade = getGrade(argv[2])
console.log(grade) console.log(grade)
function printdebug(text) {
if (DEBUG) {
console.error('DEBUG:',text)
}
}