Golf Code code error

Golf Code code error
0

#1

Tell us what’s happening:
What is wrong with my code that it keeps getting this result?

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";

  }

  

  return "Change Me";

  // Only change code above this line

}

​

// Change these values to test

golfScore(5, 4);

​

Your code so far

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 2){
    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";
  }
  
  return "Change Me";
  // Only change code above this line
}

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0.

Link to the challenge:


#2

Check your strings carefully.


#3

Thanks for the hint. I forgot the “!” in “Go Home”. :slight_smile:


#4

I guess I wasnt the only one who missed the “!” in “Go Home” - spent about 15 minutes trying to figure out why my code was wrong.