-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavgMarksOfStudents.js
More file actions
58 lines (37 loc) · 830 Bytes
/
avgMarksOfStudents.js
File metadata and controls
58 lines (37 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade.
Student Name Marks
David 80
Vinoth 77
Divya 88
Ishitha 95
Thomas 68
The grades are computed as follows :
Range Grade
<60 F
<70 D
<80 C
<90 B
<100 A
*/
getGradeOfStudents = (students) => {
var sum=0, avg=0, noofStudent=0;
for (let i in arr) {
console.log(arr[i]);
sum += arr[i];
noofStudent++;
}
avg = sum/noofStudent;
if(avg < 60) return 'F';
else if(avg < 70) return 'D';
else if(avg < 80) return 'C';
else if(avg < 90) return 'B';
else if(avg < 100) return 'A';
}
var arr = [];
arr.David = 80;
arr.Vinoth = 77;
arr.Divya = 88;
arr.Ishitha = 95;
arr.Thomas = 68;
var grade = getGradeOfStudents(arr);
console.log(grade);