-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgolf.js
56 lines (52 loc) · 1.33 KB
/
golf.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
50
51
52
53
54
55
56
function golfScore(par, strokes) {
// Only change code below this line
if (strokes === 1) {
if (par === 1 || par === 4)
return "Hole-in-one!";
} else if (strokes === 2) {
if (par === 4 || par === 5) {
return "Eagle";
}
} else if (par === 4 && strokes ===3 ) {
return "Birdie";
} else if (par === 4 && strokes === 4) {
return "Par";
} else if (par === 4 && strokes === 5) {
return "Bogey";
} else if (par === 4 && strokes === 6) {
return "Double Bogey";
} else if (par === 5 && strokes === 5) {
return "Par";
} else if (par === 4 || par === 5) {
if (strokes === 7 || strokes === 9) {
return "Go Home!";
}
}
return "Change Me";
// Only change code above this line
}
// Change these values to test
golfScore(5, 4);
/* SOLUTION FROM FCC
function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1){
return "Hole-in-one!";
} else if (strokes <= par -2){
return "Eagle";
} else if (strokes == par -1) {
return "Birdie";
} else if (strokes == par) {
return "Par";
} else if (strokes == par +1) {
return "Bogey";
} else if (strokes == par +2) {
return "Double Bogey";
} else {
return "Go Home!";
}
// Only change code above this line
}
// Change these values to test
golfScore(5, 4);
*/