FreeCodeCamp 您所在的位置:网站首页 freecadecamp FreeCodeCamp

FreeCodeCamp

#FreeCodeCamp| 来源: 网络整理| 查看: 265

Records: Golf Code In the game of Golf, each hole has a par, meaning, the average number of strokes a golfer is expected to make in order to sink the ball in the hole to complete the play. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

StrokesReturn1“Hole-in-one!”= par + 3“Go Home!”

par and strokes will always be numeric and positive. We have added an array of all the names for your convenience.

Instance Code

const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"]; function golfScore(par, strokes) { const length = names.length-1; const arerage = length / 2; if(par == strokes) { if(strokes return names[strokes - 1]; }else { const index = strokes - par + arerage; return index


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有