-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate-admission-final-score.js
More file actions
44 lines (33 loc) · 1.24 KB
/
calculate-admission-final-score.js
File metadata and controls
44 lines (33 loc) · 1.24 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
// Problem 04 : Calculate Admission Final Score
function calculateFinalScore(obj) {
if (typeof obj !== 'object' || obj === null) {
return "Invalid Input";
}
if (
typeof person.name !== "string" ||
typeof person.testScore !== "number" && typeof person.testScore <= 50 ||
typeof person.schoolScore !== "number" && typeof person.schoolScore <= 30 ||
typeof person.isFFamily !== "boolean"
) {
return "invalid input";
}
const testScore = person.testScore;
const schoolScore = person.schoolScore;
let totalScore = testScore + schoolScore;
if ( person.isFFamily === true ) {
totalScore += 20;
}
if (totalScore >= 80 && totalScore <= 100){
return true;
}
return false;
}
const person = {
name: "Saif",
testScore: 45,
schoolScore: 25,
isFFamily: true
}
// const person = "hello";
const score = calculateFinalScore (person);
console.log(score);