Skip to content
Permalink
Newer
Older
100644 26 lines (19 sloc) 640 Bytes
1
// short link: https://git.io/Jfeal
2
3
function graduation(params) {
4
let name = params.shift();
5
6
let scores = 0;
7
8
let grade = 1;
9
let graduation = 12;
10
while (grade <= graduation) {
11
let score = Number(params.shift());
12
13
if (score < 4) {
14
continue;
15
}
16
17
scores += score;
18
grade += 1;
19
}
20
21
averageScore = (scores / 12).toFixed(2)
22
console.log(`${name} graduated. Average grade: ${averageScore}`);
23
}
24
25
graduation(['Pesho', 4, 5.5, 6, 5.43, 4.5, 6, 5.55, 5, 6, 6, 5.43, 5]); // Expected Output:
26
// Pesho graduated. Average grade: 5.37