# Golf Code Instruction Question

I know how to use the comparison operators but what does this mean?

To complete this exersize are we supposed to change the operator between “par” and “strokes”?
This is what I have so far:

``````function golfScore(par, strokes) {
if (par - strokes == 3) {
return names[0];
} else if (par - strokes == 2) {
return names[1];
// This one fails.
} else if (par - strokes == 3) {
return name[1];
}
}

golfScore(5, 2);
``````

This one can’t execute as your if statement has exactly the same condition, so that one will execute

There is no need to change the operator, you can use what’s written in the table, or if you don’t like it something equivalent - but t seems you are just making things more complicated for yourself

You could just use `strokes <= par - 2`, `strokes === par - 1` etc

2 Likes

???
I do not understand.

What is it that you don’t understand?

1 Like

How to get through the exercise.
This is what I have now.

``````var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
if (par - strokes === 3) {
return names[0];
} else if (strokes <= par - 2) {
return names[1];
} else if (strokes - par == 6) {
return "Eagle";
}
return "Change Me";
}

golfScore(5, 2);
``````

You should really use just the values for strokes in the table… `Hole-in-one!` is for when `strokes` is 1

1 Like

How do I know when strokes is 1?

You don’t need to know. You create an if statement that is executed when `strokes` has value of 1.

1 Like