Home > Enterprise >  Testing a partial prorogram: Why is Modulus function not working?
Testing a partial prorogram: Why is Modulus function not working?

Time:05-02

const marks = [80];
const grade = ['A', 'B', 'C', 'D', 'F'];

let sum = 0;

console.log(checkGrade(marks));

function checkGrade(array) {
  for (let item of array)
    sum  = item;
  const avg = sum / array.length;
  let gradePoint = Math.floor((100 - avg) / 10);
  return gradePoint % 10;
}

CodePudding user response:

as Your code, the avg is = 80

and (100-avg) / 10 = 2 which is gradePoint

and you are returning gradePoint % 10

that means 2 % 10

which is returning 2. and it is working perfectly. Where is the issue?

CodePudding user response:

This is a partial program, I am testing why the modulus function is not working.

  • Related