Self teaching myself development/ES6 and having some trouble with this question I’ve been trying to work through for a little while now.
I have grades of students, and the grade threshold. Trying to return an array that contains the student’s name, place in the array, and their score converted into a letter grade.
I have the switch statement, I’m just struggling with how to use it to return an object with student name, index in the array, and letter grade, as well as how to do this with the const and fat arrow syntax.
Any help/guidance would be appreciated.
Thanks
const scoreGrades = {
A: 100,
B: 90,
C: 80,
D: 70,
F: 60,
}
const gradeReport = [{
name: ‘Abby’,
mark: 20,
}, {
name: ‘Brian’,
mark: 100,
}, {
name: ‘Chella’,
mark: 60
}];
const studentResults = (gradeReport, scoreGrades) => {
function getstudentMarks (result) {
var mark = "";
switch(true) {
case mark < 60:
grade = "F";
break;
case mark < 70:
grade = "D";
break;
case mark < 80:
grade = "C";
break;
case mark < 90:
grade = "B";
break;
case mark <= 100:
grade = "A";
break;
}
return mark;
}
var i = 1;
while(i > 0 && <= 100){
console.log(i, 'should be', getstudentMarks(i));
i += 5;
}
}