par意义,即高尔夫球手为了将球沉入洞中以完成比赛所期望的平均strokes次数。根据你的strokes高出或低于par的距离,有一个不同的昵称。您的函数将通过par和strokes参数。根据此表返回正确的字符串,该表按优先级顺序列出笔划;顶部(最高)到底部(最低): | 笔画 | 返回 |
|---|---|
| 1 | “一杆进洞!” |
| <= par - 2 | “鹰” |
| par - 1 | “小鸟” |
| 平价 | “相提并论” |
| par + 1 | “柏忌” |
| par + 2 | “双柏忌” |
| > = par + 3 | “回家!” |
par和strokes将始终为数字和正数。为方便起见,我们添加了所有名称的数组。 golfScore(4, 1)应该返回“Hole-in-one!”'
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "golfScore(4, 1) should return "Hole-in-one!"");'
- text: 'golfScore(4, 2)应该返回“Eagle”'
testString: 'assert(golfScore(4, 2) === "Eagle", "golfScore(4, 2) should return "Eagle"");'
- text: 'golfScore(5, 2)应该返回“Eagle”'
testString: 'assert(golfScore(5, 2) === "Eagle", "golfScore(5, 2) should return "Eagle"");'
- text: 'golfScore(4, 3)应该返回“Birdie”'
testString: 'assert(golfScore(4, 3) === "Birdie", "golfScore(4, 3) should return "Birdie"");'
- text: 'golfScore(4, 4)应该返回“Par”'
testString: 'assert(golfScore(4, 4) === "Par", "golfScore(4, 4) should return "Par"");'
- text: 'golfScore(1, 1)应该返回“Hole-in-one!”'
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "golfScore(1, 1) should return "Hole-in-one!"");'
- text: 'golfScore(5, 5)应该返回“Par”'
testString: 'assert(golfScore(5, 5) === "Par", "golfScore(5, 5) should return "Par"");'
- text: 'golfScore(4, 5)应该返回“Bogey”'
testString: 'assert(golfScore(4, 5) === "Bogey", "golfScore(4, 5) should return "Bogey"");'
- text: 'golfScore(4, 6)应该返回“Double Bogey”'
testString: 'assert(golfScore(4, 6) === "Double Bogey", "golfScore(4, 6) should return "Double Bogey"");'
- text: 'golfScore(4, 7)应该返回“Go Home!”'
testString: 'assert(golfScore(4, 7) === "Go Home!", "golfScore(4, 7) should return "Go Home!"");'
- text: 'golfScore(5, 9)应该返回“Go Home!”'
testString: 'assert(golfScore(5, 9) === "Go Home!", "golfScore(5, 9) should return "Go Home!"");'
```