Last active
February 2, 2018 19:25
-
-
Save iaincollins/013ebfbbd87d85730bc0c25b8429885e to your computer and use it in GitHub Desktop.
Code Golf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for https://www.freecodecamp.org/challenges/golf-code to help someone out.