<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <!-- method to declare functions in js--> <script type="text/javascript"> //Because javascript is a weak type language, the parameters do not need to be added to the type. Functions do not need to be required like c#, so the paths need to have return values (this is not like c#, and the C# method does not need to be preceded by the method name in the function keyword) function add(i, j) { //Now it is just declared that a function is here, and it will be executed only when it is called. return i + j; } alert(add(5, 6)); //Output 11 //Not all paths in js have return values. If there is no return value, it will think that the return value is undefined function sum(x, y) { if (x > y) { alert(x + y); } } var z = sum(2, 6); //Because 2 is not greater than 6, the sum function has no return value. If there is no return value, it will consider the return value to be undefined. alert(z); //So it outputs undefined </script> </head> <body> </body> </html>