-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
107 lines (98 loc) · 2.97 KB
/
index.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Student</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<table>
<thead style="border: 1px solid black;">
<tr cols-span=>
<td colspan="4"><strong>Students Result Board</strong></td>
</tr>
<tr>
<th><i>StudentName</i></th>
<th><i>RollNumber</i></th>
<th><i>TotalMarks</i></th>
<th><i>Status</i></th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
</div>
<script>
var students = [
{
name: "rajiv",
marks: {
Maths: 18,
English: 21,
Science: 45,
},
rollNumber: "KV2017-5A2",
},
{
name: "abhishek",
marks: {
Maths: 43,
English: 30,
Science: 37,
},
rollNumber: "KV2017-5A1",
},
{
name: "zoya",
marks: {
Maths: 42,
English: 31,
Science: 50,
},
rollNumber: "KV2017-5A3",
},
];
// sorting arrays in object according to names in alphabetical order;
students.sort((a,b)=>{
let fa = a.name.toLowerCase(), fb=b.name.toLowerCase();
if(fa<fb){
return -1;
}
if(fa<fb){
return 1;
}
return 0;
})
var container = document.querySelector("#container");
var tbody = document.querySelector("#table-body");
var maximumMarks = 50;
var minimumMarks = 20
var status = ''
var row = document.querySelector('.row')
students.forEach((student)=>{
//Captitalized the first letter of Name and sorted.
var studentsNames = student.name.charAt(0).toUpperCase()+ student.name.slice(1);
//Status of students
if(student.marks.English <= minimumMarks || student.marks.Maths <= minimumMarks || student.marks.Science<=minimumMarks){
status = "Failed";
}else if (student.marks.English >= maximumMarks || student.marks.Maths >= maximumMarks || student.marks.Science >= maximumMarks) {
status = "Topper"
} else {
status = "Passed"
}
var tr = `<tr class = "row">
<td>${studentsNames}</td>
<td>${student.rollNumber}</td>
<td>${student.marks.English + student.marks.Maths+student.marks.Science}</td>
<td>${status}</td>
</tr>`
tbody.innerHTML += tr;
});
var setColor = this.tbody.children;
setColor[1].setAttribute("style","color:red;")
setColor[2].setAttribute("style","color:green;");
</script>
</body>
</html>