When defining the function UpdateScoreBy I noticed that the parameter “amt” is not mentioned anywhere else as a variable or in design mode as a UI object label. I realize this stands for amount, but I don’t understand how the computer knows what this means or is supposed to do. I looked through the documentation on App Lab (at least as much as I could figure out) and the W3Schools references, but didn’t see amt.
When defining a function you can include parameters (information that is going to be sent to the function). When using parameters, you do not need to declare them as variables.
// Function Call
UpdateScoreBy(3);
UpdateScoreBy(-1);
// Function Definition
function UpdateScoreBy (amount){
}
The first function call sends the value 3, so the function assigns 3 to amount. And inside the function amount represents 3.
The second function call sends the value -1, so the function assigns -1 to amount. And inside the function amount represents -1.
You can label your parameters whatever label makes sense - amt or amount or Amnt.