# Could I please draw someone's attention to this matter?

I hate to say it like this, but I really am not catching on to this challenge. Trying to piece it up so that I do not look at the answer… Could anyone shed light here, please?

I am having a hard time understanding how to interpret the chart that we are to use to implement the if statements but I just can not seem to piece it together. Again, I really would like to understand the logic (how to implement the if statements ( stroke === 4 && par === 3 ) the relation of this code to the chart that is provided in the challenge. Thanks in advance.

``````  **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

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

golfScore(5, 4);
``````
``````  **Your browser information:**
``````

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36`

Challenge: Golf Code

What have you tried so far? Have you used `if` statements before?

I actually have, and I am alright using counters and accessing [i] of a counter BUT for some reason I just can’t see to process the interpretation of the chart used to represent the data in the tutorial itself. As I said, I took a peek but I am not trying to get the answer but the logic to how to do it myself.

Yeah, I had to turn my head a little bit when I first saw that chart.

It is trying to tell you that…

If `strokes === 1`, it is a hole in 1.

If `strokes <= (par -2)`, it is an eagle.

Does that makes sense?

Just to make it clear, I’m referring to the table in the challenge in www.freecodecamp.org that I am currently working on. The table that shows the strokes and the return or the classification based on scores " Eagle or Birdie " THAT TABLE. par + 1 , par + 3 stuff…

You don’t have to worry about iteration in this case.
Each row on the table will correspond to an `if` statement, where you (usually) compare `strokes` to `par`.

Ok! Yes, that! So, you’re saying …

so,

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

Would that be the right implementation to return “Go Home” ?

Yeah, that’s the basic idea. There are more details to complete this, but that is what that table is trying to tell you.

I’m trying to find the logic behind the if statement:
well, it just baffles me, so …

``````else if (strokes === (par)){
return "Par";
}
``````

That there is mind-boggling but I’ll just keep moving forward. It just isn’t sticking right now but gotta move forward.

In golf, a certain hole has a “par” or expected score. If your number of strokes is exactly equal to the par, then you’ve “made par”.

That there is mind-boggling

What, the mathematical logic or how golf works?

``````else if (strokes = (par)){
``````

This shouldn’t actually work. You’ve used the assignment operator (`=`) instead of one of the comparison operators (`==` or `===`).

2 Likes

correction made. I understand that it has to be strictly equal. strictly.

I’m gonna get on to the implementation. Let’s make it happen. Let’s get it to work.

It would also work with the standard equality operator, `==`, in this case. But we should be using strictly equal, `===`, by default. The issue wasn’t that, it was that you were using the assignment operator, `=`, something entirely different.

Good. See what you come up with. If you run into trouble, ask away, but please include your code so we can guide you.

Thanks man. I am very grateful for the support that I’ve found here. Indeed I am .

1 Like

I actually was not using the assignment operator man, I just could not figure out what you shared with me. That what I asked you if my interpretation was adequate => that =>

``````else if (strokes === (par)){
return "Par";
}
``````

You did post some code where you were using `=`.

I’m not sure why you put the `()`s around `par`?

Well, I was under the impression that we should. How are you referring me to do it?

I used extra parentheses when I posted:

If `strokes <= (par -2)` , it is an eagle.

I did it for clarity, but they aren’t needed. They especially aren’t needed if it is just a number.