'Testing a partial prorogram: Why is Modulus function not working? [closed]

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;
}


Solution 1:[1]

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?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Razu Ahmed Joy