par
,代表着距离。根据你把球打进洞所挥杆的次数strokes
,可以计算出你的高尔夫水平。
函数将会传送 2 个参数,分别是标准杆数par
和挥杆次数strokes
,根据下面的表格返回正确的水平段位。
Strokes | Return |
---|---|
1 | "Hole-in-one!" |
<= par - 2 | "Eagle" |
par - 1 | "Birdie" |
par | "Par" |
par + 1 | "Bogey" |
par + 2 | "Double Bogey" |
>= par + 3 | "Go Home!" |
par
和strokes
必须是数字而且是正数。
golfScore(4, 1)
应该返回 "Hole-in-one!"。
testString: assert(golfScore(4, 1) === "Hole-in-one!");
- text: golfScore(4, 2)
应该返回 "Eagle"。
testString: assert(golfScore(4, 2) === "Eagle");
- text: golfScore(5, 2)
应该返回 "Eagle"。
testString: assert(golfScore(5, 2) === "Eagle");
- text: golfScore(4, 3)
应该返回 "Birdie"。
testString: assert(golfScore(4, 3) === "Birdie");
- text: golfScore(4, 4)
应该返回 "Par"。
testString: assert(golfScore(4, 4) === "Par");
- text: golfScore(1, 1)
应该返回 "Hole-in-one!"。
testString: assert(golfScore(1, 1) === "Hole-in-one!");
- text: golfScore(5, 5)
应该返回 "Par"。
testString: assert(golfScore(5, 5) === "Par");
- text: golfScore(4, 5)
应该返回 "Bogey"。
testString: assert(golfScore(4, 5) === "Bogey");
- text: golfScore(4, 6)
应该返回 "Double Bogey"。
testString: assert(golfScore(4, 6) === "Double Bogey");
- text: golfScore(4, 7)
应该返回 "Go Home!"。
testString: assert(golfScore(4, 7) === "Go Home!");
- text: golfScore(5, 9)
应该返回 "Go Home!"。
testString: assert(golfScore(5, 9) === "Go Home!");
```