-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.html
More file actions
44 lines (39 loc) · 819 Bytes
/
array.html
File metadata and controls
44 lines (39 loc) · 819 Bytes
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
41
42
43
44
<html>
<head>
<title>ARRAY</title>
</head>
<body>
<form>
<h3>Here is the 1st array</h3><br>
<h3>1 3 5 7 9 </h3><br>
<h3>Here is the 2nd array</h3><br>
<h3>2 4 6 8 10</h3><br>
<h3>Click Submit to interchange the values</h3>
<button onclick="swap();">SUBMIT</button>
</form>
<script>
var arr1 = ["1","3","5","7","9"]
var arr2 = ["2","4","6","8","10"]
function swap()
{
var i,temp;
for (i=0;i<5;i++)
{
temp = arr1[i];
arr1[i] = arr2[i];
arr2[i] = temp;
}
for(i=0;i<5;i++)
{
document.write("1st array:-"+ "<br >");
document.write(arr1[i] + "<br >");
}
for(i=0;i<5;i++)
{
document.write("2nd array:-"+ "<br >");
document.write(arr2[i] + "<br >");
}
}
</script>
</body>
</html>