debugging statements that i needn't remove
This commit is contained in:
13
main.mjs
13
main.mjs
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user