Why are functions done this way in the app lab?

For instance in the app lab this is how functions are called:

onEvent(“button1”, “click”, function() {
checkCorrect(“button1”);
});


However isn’t the standard format in javascript: function functionName { };

Also why is there a parenthesis at the end of the entire function as well?

This is an onEvent block that is calling a function when button1 is clicked. The function is a parameter of the onEvent block. The ending parenthesis is for the parameter list.

Ah I see, so is onEvent a built-in function from code.org?

So you are saying that functions can take another function as a parameter? If onEvent is a function.

Yes, functions can be passed as parameters. Here is an article I found that may help. :slightly_smiling_face: