I'm quite confused

Tell us what’s happening:

I’m a bit confused about the Golf code challenge, can i get a reference of a full explanation of the Golf code challenge.

Your code so far


var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
// Only change code below this line
  if(par <= 4 strokes == 1){return "Hole-in-one!"}
  else if(par <= 4 strokes == 2){return "Eagle"}
  else if(par <= 5 strokes == 2){return "Eagle"}
  else if(par <= 4 strokes == 3){return "Birdie"}
  else if(par <= 4 strokes == 4){return "Par"}
  else if(par == 1 strokes == 1){return "Hole-in-one!"}

return "Change Me";
// Only change code above this line
}

golfScore(5, 4);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0.

Challenge: Golf Code

Link to the challenge:

Your issue is that this is not a valid logical condition.

You’re not using the required conditions:
image

1 Like

The code you posted has several syntax errors. You will need to fix them also. But first, let’s talk about your overall logic. The table shows what you should be comparing strokes against to determine what to return. You seem not to understand what you should be comparing. For example, for "Hole-in-one!", you do not care about par. Instead, you should only care that strokes is equal to 1. For the others, you will only need to compare strokes to something related to par. See if you can get the first case solved and then add other logic to get the other test cases to pass.

1 Like