-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial6 Functions2.html
More file actions
30 lines (28 loc) · 1.11 KB
/
Tutorial6 Functions2.html
File metadata and controls
30 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!doctype html>
<html>
<head>
<title>
Tutorial 6 JavaScript -- Function with arguments
</title>
</head>
<body>
<script type="text/javascript"> // Tag to include JavaScript in HTML.
// defining a function. Function is a keyword.
function addnumber(x,y){
document.write("Sum: " + (x+y)+"<br />");
}
addnumber(4,5); // Calling a function.
/* Take Aways: - The above function use two parameters and prints the sum. Remember parameters are passed positionly.
*/
function sumreturn(x,y){
return(x+y);
}
var x = sumreturn(7,8);
document.write("Returned Sum: "+ x);
/* Take Aways: - The above function use two parameters and returns the sum. Remember parameters are passed positionly.
- Whenever we use return statement we should use a variable to recieve the returned value.
- Make sure definition and function call use same number of arguments.
*/
</script>
</body>
</html>