-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionDemo.html
More file actions
40 lines (38 loc) · 1.06 KB
/
FunctionDemo.html
File metadata and controls
40 lines (38 loc) · 1.06 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
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//define function
function sum(num1,num2){
var total = num1+num2;
document.write('The adittion of 2 numbers : '+total);
}
//function witj return statement
function getRectArea(width,height){
if(width>0 && height>0){
return width*height;
}
}
</script>
</head>
<body>
<h1 style="color: blue;"> JavaScript Functions Demo </h1>
<hr>
<script>
sum(10,30);
document.write("<br>");
sum(20,40);
document.write("<br>")
sum(-1,3);
</script>
<h1 style="color: blue;"> JavaScript function with return statement </h1>
<script>
var area = getRectArea(10,20);
document.write("<br>The area of REctangle is : "+area);
document.write("<br>The area of REctangle is : "+getRectArea(15,0));
</script>
</body>
</html>