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