Javascript basi...LOGIN

Javascript basic tutorial function with parameters

Function with parameters

Syntax:

function sum(parameter 1, parameter 2){

Function code;

}

Note: According to the needs of partners, there are not fixed 2 parameters, one can be used, or 3 can be used

Let’s write an example of a function with parameters, the code As follows:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>函数</title>
	<script type="text/javascript">
			function sum(a,b){
				var c= a+b;
				document.write(c);
			}

			sum(3,5);
	</script>
</head>
<body>

</body>
</html>

In this way, the code of our function will be relatively concise

Let’s write an example below:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>函数</title>
	<script type="text/javascript">
			function sum(a,b){
				var c= a+b;
				document.write(c);
			}

			sum("欢迎来到","php中文网");
	</script>
</head>
<body>

</body>
</html>


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>函数</title> <script type="text/javascript"> function sum(a,b){ var c= a+b; document.write(c); } sum("欢迎来到","php中文网"); </script> </head> <body> </body> </html>
submitReset Code
ChapterCourseware