forked from MedTech-CS425/StudentManagementSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentManagementSystem.js
More file actions
345 lines (268 loc) · 7.31 KB
/
StudentManagementSystem.js
File metadata and controls
345 lines (268 loc) · 7.31 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
function add (number1, number2){
return number1 + number2
};
add(1,2);
var numberOfStudents = 0;
function addStudent(){
numberOfStudents = numberOfStudents + 1;
};
console.log(numberOfStudents);
addStudent();
console.log(numberOfStudents);
addStudent();
console.log(numberOfStudents);
function getNumberOfStudents() {
console.log(numberOfStudents);
return numberOfStudents;
};
getNumberOfStudents();
addStudent();
getNumberOfStudents();
var students = [];
clearStudents();
function addStudents(student){
students [numberOfStudents] = student;
numberOfStudents = students.length;
};
console.log(students);
addStudents("Josh");
console.log(students);
console.log(numberOfStudents);
addStudents("John");
console.log(students);
function clearStudents() {
clear = [];
students = clear
numberOfStudents = 0;
};
console.log(students);
getNumberOfStudents();
clearStudents();
console.log(students);
getNumberOfStudents();
function createFullName(firstName, lastName){
return firstName + " " + lastName;
};
clearStudents();
getNumberOfStudents();
console.log(students);
addStudents(createFullName("Josh", "Bull"));
addStudents(createFullName("John", "Doe"));
addStudents(createFullName("Aziz", "Rourou"));
addStudents(createFullName("Aziz", ""));
addStudents(createFullName("", "Rourou"));
getNumberOfStudents();
console.log(students);
function getStudentByInitials(name, initial) {
if (name.charAt(0)==initial) {
console.log("true");
return true;
} else {
console.log("false");
return false;
}
}
getStudentByInitials("Josh", "J");
getStudentByInitials("Josh", "A");
function isFullName(name) {
const str = ""+name;
const words = str.split(' ');
var count = words.length;
if (count>1) {
console.log("true");
return true;
} else {
console.log("false");
return false;
};
};
isFullName("John Doe");
isFullName("John");
function getStudentsByInitials(initial) {
var result = [];
let i = 0;
for (let index = 0; index < students.length; index++) {
if(students[index].charAt(0)==initial){
result[i]=students[index]
i=i+1;
}
};
console.log(result);
return result
};
console.log(students);
getStudentsByInitials("J");
function getStudentsByInitials_v2(firstInitial,
secondInitial) {
var result = [];
let i = 0;
for (let index = 0; index < students.length; index++) {
if(isFullName(students[index])){
const str = ""+students[index];
const words = str.split(' ');
if((words[0].charAt(0)==firstInitial)&&(words[1].charAt(0)==secondInitial)){
result[i]=students[index]
i=i+1;
}
}
};
console.log(result);
return result
}
console.log(students);
getStudentsByInitials_v2("J", "D");
function createStudent(firstName, lastName, email, age,
education) {
var student = {
firstName: firstName,
lastName: lastName,
fullName: createFullName(firstName, lastName),
email: email,
age: age,
education: education,
skills: []
};
console.log(student);
return student
}
var student1 = new createStudent("Aziz", "Rourou", "aziz.rourou.99@gmail.com", 21,
"SE");
function addSkills(student, sklls) {
var arr = Array()
arr= arr.concat(student.skills)
arr=arr.concat(sklls)
student.skills = [...new Set(arr)];
}
addSkills(student1,["hatml","css","dz"])
console.log(student1.skills)
clearStudents();
console.log(students)
addStudents(createStudent("tamer", "galai", "aziz.com", 21,
"SE"))
function removeStudent(firstName) {
for (let index = 0; index < students.length; index++) {
if (students[index].firstName == firstName) {
students.splice(0, 1);
numberOfStudents = students.length
};
}
}
console.log(students);
console.log(numberOfStudents);
removeStudent("tamer")
console.log(students)
console.log(numberOfStudents)
function addSkills(student, sklls) {
var arr = Array();
arr = arr.concat(student.skills);
arr = arr.concat(sklls);
student.skills = [...new Set(arr)];
};
var student1 = createStudent("John","Doe",
"john.doe@gmail.com", 25, "CS");
console.log(student1.skills);
addSkills(student1, ["HTML", "CSS"]);
console.log(student1.skills);
addSkills(student1, ["Javascript", "CSS"]);
console.log(student1.skills);
clearStudents();
delete me;
addStudents(createStudent("firstn", "lastn","email@gmail.com",22,"RE"));
console.log(students);
console.log(numberOfStudents);
addStudents(createStudent("second", "student","email@gmail.com",22,"SE"));
console.log(students);
console.log(numberOfStudents);
function removeStudent(firstName) {
for (let index = 0; index < students.length; index++) {
if (students[index].firstName == firstName) {
students.splice(index, 1);
numberOfStudents = students.length
};
}
}
console.log(students);
console.log(numberOfStudents);
removeStudent("second");
console.log(students);
console.log(numberOfStudents);
removeStudent("firstn");
console.log(students);
console.log(numberOfStudents);
function isStudentOlderThan(student, age) {
if (student.age > age)
{
return console.log( "true")
}else {
return console.log( "false")
}
}
var student3 = new createStudent("thamer","galai","zaaer",23,"fddgdg","fdfgsdqg")
var student1 = createStudent("ohn", "Doe",
"john.doe@gmail.com", 25, "C")
isStudentOlderThan(student1,70)
isStudentOlderThan(student1,20)
function doesStudentHaveSkills(student) {
if (student.skills.length != 0 ) {
return console.log("true")
}else
{
return console.log("aaalse")
}
}
var student5 = createStudent("tttttohn", "Doe",
"john.doe@gmail.com", 25, "C")
doesStudentHaveSkills(student5)
addSkills(student5,["tamiiira","sfdsdf"])
console.log(student5.skills)
doesStudentHaveSkills(student5)
doesStudentHaveSkills(student3)
function isStudentQualified(student) {
if ( doesStudentHaveSkills(student) && isStudentOlderThan(student,18)) {
return true
}
else {
return false
}
}
var student7 = createStudent("tttttohn", "Doe",
"john.doe@gmail.com", 20, "C")
isStudentQualified(student7)
addSkills(student7,["sd","sfdsdf"])
console.log(student7.skills)
isStudentQualified(student7)
function numberOfStudentsOlderThan(age) {
var count = 0;
for (let index = 0; index < students.length; index++) {
if (isStudentOlderThan(students[index],age)) {
count =index
count++
}
}
return count;
}
clearStudents();
console.log(students);
var student1 = createStudent("Ben", "Vega",
"ben.vega@gmail.com", 25, "RE");
addStudents(student1);
var student2 = createStudent("Josh", "Hep",
"josh.hep@gmail.com", 26, "CS");
addStudents(student2);
var student3 = createStudent("Jane", "Nash",
"jane.nash@gmail.com", 28, "CSE")
addStudents(student3)
console.log(numberOfStudentsOlderThan(25));
function getStudentsWithSkills() {
var res =[];
var i =0;
for (let index = 0; index < students.length; index++) {
if (doesStudentHaveSkills(students[index])) {
res[i] = students[index];
i=i+1;
}
}
return res;
}
addSkills(student1, ["HTML", "CSS"]);
getStudentsWithSkills()