Golf Challenge - Help w my code

Hi folks - having trouble with this one. Seems like most of the problems other people have had are with typos so I’ve triple checked my code and don’t see any typos.

The code works up until a score of par where it then it falls apart. Can anyone help?

// 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

You should have 2 `=``s here.

You should check if it is par+3 or higher.

1 Like

Gah! thank you! That solved the problem :grinning:

1 Like

Also a quick tip, you could change

else if (strokes === par +3){
return "Go Home!";
}

to

 else
  {
    return "Go Home!";
  }

Instead of having a chain of if else statements with no else statement to clear up.

i spent 6 hours staring at the problem because i had Hole-in-One! instead of Hole-in-one!

I fee your pain…I too have lost a bit of time because of small little things like this. I’m glad you were able to figure it out.

1 Like