I'm working on this problem for school, our assignment calls for us to make a function that returns a boolean data type. I made the function and have the parameters pushed through to the array. For some reason when I run the code it will give back the "null" value but not the true or false values for the comparison.
below is my code, I'm new to Javascript, please point out any bad practices I may have used.
let classList = [];
const enrollStudent = (firstName, lastName, age, currentMark) => {
let newStudent = {firstName: firstName, lastName:lastName, age, currentMark};
classList.push(newStudent);
};
const getClassAverage = () => {
let sum = 0;
classList.forEach(classList => {
sum = sum + classList.currentMark
return sum / numStudentEnrolled();
});
}
/* problem seems to be in here */
const studentAboveClassAverage = (student) => {
if(student.currentMark > getClassAverage()) {
return true
}
if(student.currentMark < getClassAverage()) {
return false
}
if(student.currentMark === getClassAverage()) {
return null
}
};
/* problem seems to be in here */
Aucun commentaire:
Enregistrer un commentaire