我如何解决此问题以显示成绩

时间:2019-11-26 15:50:48

标签: loops

**编写程序以计算成绩

  1. 平均分数
  2. 1-59:F
  3. 60-69:D
  4. 70-79:C
  5. 80-89:B
  6. 90-100:A

**

```
let marks = [100,100,100];
console.log(calculateGrade(marks));
 function calculateGrade(marks) {     
 var total = 0;
 var sum = 0;
 for (let total of marks)
 sum +=total; 
 sum /= marks.length;
 return (( sum <=59 || sum <=69 ? 'F' : 'D') && ( sum <=79 || sum <=89 ? 'C' : 'B'));
 (sum >= 90)console.log('A');
  }


1 个答案:

答案 0 :(得分:0)


console.log(calculateGrade(marks));
function calculateGrade(marks) {
     var total = 0;
     var sum = 0;
     for (let total of marks)
     sum +=total; 
     average = sum / marks.length;
     console.log(average);
     // return ((((average = 0 && average <=59) && (average = 60 && average <=69) ? 'F' : 'D')) && (((average = 70 && average <=79) && (average = 80 && average <=89) ? 'C' : 'B')));
     // else console.log('A');
     if ( average < 60) return "F";
     if ( average < 70) return "D";
     if ( average < 80) return "C";
     if ( average < 90) return "B";
      return "A";
      }