Functions with more than one parameter

In the previous sample code, we looked at how to use a parameter in a function. This sample code shows how to use multiple parameters. Make sure you also watch the video that explains functions and parameters here.

<!DOCTYPE html>
<html lang="en"
 <meta charset="utf-8"/>
 <title>JavaScript - Functions with multiple parameters</title>
 <script type="text/javascript">
 // define the function and set the parameters separated by comma
 function addNumbers(num1, num2){
 // function code goes here, eg:
 var answer = num1 + num2;
 document.write(answer + "<br/>");
 // call the function three times with different parameters
 // notice that there is a <br/> tag in the function, so a new line will be added each time the function is called