Defining Functions
You're on a roll!
OK, now we've gotten familiar with JavaScript variables and values, let's get down to the real business, functions.
Here is the definition of a function called plusOne that adds one to its argument.
Here's code that uses the function to set the value of y.
The variable y is set to 11, because 10 + 1 is 11.
Functions can take more than one argument. Here is a function that takes two arguments.
Define a function named add that takes two arguments x and y, and returns the sum of x and y.
1:1