Skip to content

Instantly share code, notes, and snippets.

@iaincollins
Last active February 2, 2018 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaincollins/013ebfbbd87d85730bc0c25b8429885e to your computer and use it in GitHub Desktop.
Save iaincollins/013ebfbbd87d85730bc0c25b8429885e to your computer and use it in GitHub Desktop.
Code Golf
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
}
// Change these values to test
golfScore(5, 4);
@iaincollins
Copy link
Author

Example for https://www.freecodecamp.org/challenges/golf-code to help someone out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment