I was doing some javascript exercises and although I did manage to make this one correctly, I'm pretty confused.
So this is an exercise where the average of a list of marks has to be compared with a given value range to return a string that responds whether the mark was sufficient or not. I found that when compare using a > operator, it returns undefined. Even if the upper limit is also given and that alone (without the lower border value + > operator) does return the string. I don't really understand why this is.
Thanks for your help
const marks = [ 80, 80, 50 ]
console.log (calculateGrade (marks));
function calculateGrade(marks) {
let markstotal=0;
for (let mark of marks)
markstotal += mark;
let average = markstotal / marks.length;
if (average <= 59)
return "F";
if (average < 59)
return "mehh";
if (average > 70 && average < 90)
return "oh yeah mate";
}