To format, you can wrap code in back ticks ( ` ) to format it for single-line or inline items. If you want multi-line code, you can indent by four spaces without the backticks:
*Also, it could be helpful to post the errors you are getting or more of a description on the specific problem you are having to the forum so people can better help you
Actually, @JesseNuese your problem is even simpler than forgetting to delete the return “Change me” line: the FCC validator is expecting the hole in one line to read “Hole-in-one!” you left out the exclamation point. just changing that (even leaving in the extraneous return statement since the code never gets to it anyhow) will make your code pass.
I’m so glad I read this, looked back at my work and saw the typo “par” instead of “Par”. It was super frustrating up until then as everything was working but wouldn’t pass!
is strict equality required here? I got past the challenge with just ==
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 if (strokes >= par +3) {
return “Go Home!”;
}
// Only change code above this line
}
The last line can be written with only an else statement, since it does not matter how bad your strokes are and we fulfill the “DRY” coding part.
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);