Find the solution of the Golf Code

Find the solution of the Golf Code
0

#1

finally, I have completed golf code challenge.

var names = [“Hole-in-one!”, “Eagle”, “Birdie”, “Par”, “Bogey”, “Double Bogey”, “Go Home!”];

function golfScore(par, strokes){
if(par <= 5 && strokes == 1){
return names[0]; // Hole-in-one
}
else if(par <=5 && strokes <= par-2){
return names[1]; // Eagle
}
else if(par <= 5 && strokes == par-1){
return names[2]; // Birdie
}
else if(par <= 5 && strokes == par){
return names[3]; // par
}
else if(par <= 5 && strokes == par+1){
return names[4]; // Bogey
}
else if(par <= 5 && strokes == par+2){
return names[5]; // Double Bogey
}
else if (par <= 5 && strokes >= par+3){
return names[6]; // Go Home
}

else{
return “Change Me”;
}
}

var getScore = golfScore(1,2);


#2

Hey @vinaykotturi,
Please use spoiler tags when posting working solutions to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.