Tell us what’s happening:
I passed the test quite alright with some help from the hint but can someone please throw more light on pars and strokes so I can understand it better. Thank you
Your code so far
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
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
}
golfScore(5, 4);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134.
pars and strokes are a golf thing
with the par being the average number of strokes the player you need to put the ball in the hole, and strokes being the number of throws they need.
This is not a code thing, but if you are interested to learn more about golf, I suggest wikipedia.
but if you want some suggestions at getting better…
you have an array with the values as first line of your code, you could use that array instead of risking typos while hardcoding the strings
I must be honest your replies have been super helpful. I think I will prefer using the array method. I will appreciate more insightful tips from you as I hope to get better eg//will this equally execute
if (strokes==1){
return “Hole-in-one!”;
}else if (strokes<=2){
return “Eagle”;
}… etc will this code also execute.
do you mean the strokes <= 2?
it will not give the required output as you need to compare strokes to par to know what string to returns, here you are not