-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproblem40.js
49 lines (34 loc) · 1.22 KB
/
problem40.js
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
/* Can you find out who will get the delicious cake?
(Part II)
This year, not only Jim & Dela but also Chinku are doing hard work to secure the first position. Can you find out who will get the delicious cake?
**Input: The input line has three values, x (The marks Jim has got), y (The marks Dela has got) and z (The marks Chinku has got)**
**Output: Print the name of the topper.**
1. Sample Input-1: 84 99 77
- Sample Output-1: Dela
2. Sample Input-2: 69 97 99
- Sample Output-2: Chinku */
function findingTopper(x, y, z){
if((typeof x === "number") && (typeof y === "number") && (typeof y === "number") ){
if ( x > y && x > z) {
const cakeWinner = "Jim";
return cakeWinner;
}
else if( y > x && y > z){
const cakeWinner = "Dela";
return cakeWinner;
}
else{
const cakeWinner = "Chinku";
return cakeWinner;
}
}
else{
const errorMassage = "Please inter number value (marks)";
return errorMassage;
}
};
const jimsMarks = 69;
const delasMarks = 97;
const chinkusMarks = 99;
const theCakeWillGet = findingTopper(jimsMarks, delasMarks, chinkusMarks);
console.log(theCakeWillGet);