Golf Code - Unexpected Identifier

I’m stuck here. Where did I go wrong? Please I badly need your help

Your code so far

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 (stokes == 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"; 
  } else {
  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(4, 1);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/golf-code

That line is a syntax error, you’re missing a comparison operator.

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"; 
  } else {
  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(3, 1);
  • I’m still stuck :frowning:

“unexpected identifier” is most often an error resulting in missing or misplaced parentheses, brackets, or braces. Check and make sure that every opening { has a matching } in the right place.

1 Like

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

1 Like

Oh I missed one bracket. Thanks btw!


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!";
  } else {
    return "Change Me!";
  }
  // Only change code above this line
}
// Change these values to test
golfScore(4, 1);