Into the Putts explainer

Aim of the puzzle: Add parameters to a function declaration.
Walk through of solution: A parameter is a special type of variable that is used to specify the input of a function.

Parameters are defined inside the parentheses () of a function declaration, and behave like a variable inside a function. They only exist inside the function declaration.

In this puzzle, the underPar() function has 2 parameters, score and par. The function then returns the par minus the score.

At the bottom of the code, the function is called with 2 arguments, for example, 10 and 11. Whichever number is placed in the parentheses first will serve as the score (as that is the first parameter), and the second number will become the par. The function will then return 11 - 10, or 1.
Sample code solution:

function underPar(score, par) {
    return par - score;
}

console.log(underPar(10, 11));

Javascript Concepts: Parameters, Arguments, Functions, Return Statements

Hallo, my code in „Into the Putts“ is correct, but I cannot go on.
My code:
function underPar(par, score) {
return par - score;
}
console.log(underPar(5, 4));

It Workshop and the result is 1.
There must be a bug in the program.

Hey there, try updating the app to the current version. There was a bug preventing this puzzle from working properly, and the fix was released a few weeks ago.

If you update the app and this puzzle is still not working, please let me know.

Thanks!
Ben

1 Like

Seems to still be acting weird for me. Won’t let me input score or par, or if it does, it changes par to score or vise versa

Hmm, try submitting a bug report through the app.

Try running the code in the puzzle once or twice, then tap on the menu button in the top-right of the screen, then “Send Feedback” ==> “Report a Problem”.

A bug report will send us Grasshopper’s logs, which we can use to figure out what is going on under the hood.

Thanks for your patience,
Ben

It looks like this puzzle is missing the par and score auto fill options (for me at least). When I try to type it in manually my entry is rejected.

Hey there,

Part of completing this puzzle is manually adding the parameters, which you will need to type yourself. Can you tell me more about what happens when the parameters are rejected? Is there a message displayed at all?

Thanks,
Ben

Got it, rather than pressing done I was trying to separate the two parameters with a comma manually. Thats what caused the rejection.

Hello, to calculate score in golf, it should be score - par. I gave myself a realistic score of one over par 4, 3 and it returns -1. It made me question everything I knew!

Thanks, loving this app.

Thanks for the tip! To be honest, there aren’t a lot of golfers on staff here at Grasshopper.

Ben

Save it for when you’re retired like everyone else. Looks like you need a little more diversity!

Thanks for the reply