Tell us what’s happening:
I can’t understand the whole question. I read the full details given in the lesson. i can’t understand.
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 (Windows NT 6.1; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0.
Hi there,
first of all, let’s talk about golf.
You need to shoot the ball, but often your shot is either far behind the hole or below the hole. If you need par - two strokes to send the ball then it is called “Eagle” .
Par is the average number of strokes.
For example, if you need >= more than Par + 3 strokes then you need " go home". Basically, this is what it’s called.
Now in this lesson, you call the function which is golfScore( ); and you pass two arguments to the function. Those two arguments are par and strokes.
If this argument equals this strokes <= par - 2 then it should return “Eagle”. The default value for strokes is 1.
You can use conditional statements to return the callings.
Go through the chart of possible strokes and create conditions for each possible scenario from 1 all the way through to >= par + 3 using the formulae that @anon58011934 laid out for you.
If you look at the chart though it says if strokes is 1 then return “Hole in one”. So try to see if you can incorporate strokes in all of your if statements.
All if/else statements should all include strokes with the exception of the last else statement.
For the last else statement it shouldn’t be else if it should just be an else.
Remember that an else block is going to look different than an if or else if.
Here is a hint on how to write that last else statement.
None of these have any conditional operators in them. They aren’t testing for anything. Try reading them out loud to see if they make sense “If par plus one plus strokes”.
Also remember that = does not check for equality. It is the assignment operator.
I would suggest going through the strokes and return chart in the challenge and saying out loud each of those statements before translating that into code.