Now it takes two parameters. A function contains code that will be executed by an event or by a call to that function. Because of this weird behavior, and because function names are case sensitive, it makes sense to have a different convention for naming functions than for naming variables.
Syntax The basic syntax is shown here. Next Page A function is a group of reusable code which can be called anywhere in your program. No other characters, including spaces, are allowed. But there is a facility to pass different parameters while calling a function.
So, functions that are going to return a value must use the return statement. We have modified our sayHello function here. To add a space between two string variables, insert a space into the expression, OR in one of the strings.
Names in this notation style consist of strings of words without spaces, in which every word except the first is initial-capitalized, as in openAndCenterTheWindowmyCatand printDate.
Even more problematic, if you want to change the code to affect window size or centering, you have to make the change everywhere you put the link.
The rules for naming a function are similar to those for naming a variable. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
Also note that you must call a function with the exact same capitals as in the function name. A function can take multiple parameters separated by comma. A function with no parameters must include the parentheses after the function name: These passed parameters can be captured inside the function and any manipulation can be done over those parameters.
Function names can contain letters, digits, underscores, and dollar signs (same rules as variables). Note: many of the contents of this page are taken from w3school website.
How TO - Alerts Alerts. Alert messages can be used to notify the user about something special: danger, success, information or warning.
An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed. Syntax.Download