-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray methods
More file actions
152 lines (130 loc) · 4.65 KB
/
Array methods
File metadata and controls
152 lines (130 loc) · 4.65 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// push,pop,shift,unshit,splice,slice,gethour(),getday(),getFullYear//
<html>
<head>
<title> web programming </title>
<style>
p{
font-weight: bold;
font-size: 30px;
width: fit-content;
background-color: aqua;
}
</style>
</head>
<body>
<h1> ARRAY METHODS : </h1>
<h2> PUSH </h2>
<p id="PIET1"></p>
<button onclick="KVSR()">KVSR</button>
<h2> POP </h2>
<p id="PIET2"></p>
<button onclick="KVSR1()">KVSR1</button>
<h2> SHIFT </h2>
<p id="PIET3"></p>
<button onclick="KVSR2()">KVSR2</button>
<h2> UNSHIFT </h2>
<p id="PIET4"></p>
<button onclick="KVSR3()">KVSR3</button>
<h2> SPLICE </h2>
<p id="PIET5"></p>
<button onclick="KVSR4()">KVSR4</button>
<h2> SLICE </h2>
<p id="PIET6"></p>
<button onclick="KVSR5()">KVSR5</button>
<h2> get hours </h2>
<p id="PIET7"></p>
<button onclick="KVSR6()">KVSR6</button>
<h2> get day </h2>
<p id="PIET8"></p>
<button onclick="KVSR7()">KVSR7</button>
<h2> get full year </h2>
<p id="PIET9"></p>
<button onclick="KVSR8()">KVSR8</button>
<script>
function KVSR()
{
var students = ["venkata" , "avinash" , "vrushodhar" , "harsha vardhan", "sridhar"];
students.push("sai kumar");
document.getElementById("PIET1").innerHTML = students;
}
function KVSR1()
{
var students1 = ["venkata" , "avinash" , "harsha vardhan" , "bharagav", "sridhar" , "vrushodhar"];
students1.pop();
document.getElementById("PIET2").innerHTML = students1;
}
function KVSR2()
{
var students2 = ["tarun" ,"venkata" , "avinash" , "harsha vardhan" , "bharagav", "sridhar" , "vrushodhar"];
students2.shift();
document.getElementById("PIET3").innerHTML = students2;
}
function KVSR3()
{
var students3 = ["tarun" ,"venkata" , "avinash" , "harsha vardhan" , "bharagav", "sridhar" , "vrushodhar"];
students3.unshift("sai kumar");
document.getElementById("PIET4").innerHTML = students3;
}
function KVSR4()
{
var students4 = ["tarun" ,"venkata" , "avinash" , "harsha vardhan" , "bharagav", "sridhar" , "vrushodhar"];
students4.splice(2,1,"sai");
document.getElementById("PIET5").innerHTML = students4;
}
function KVSR5()
{
var students5 = ["tarun" ,"venkata" , "avinash" , "harsha vardhan" , "bharagav", "sridhar" , "vrushodhar"];
students5.slice(2,4);
document.getElementById("PIET6").innerHTML = students5.slice(2,4);
}
</script>
<script>
function KVSR6()
{
const d = new Date();
document.getElementById("PIET7").innerHTML = d.getHours();
}
</script>
<script>
function KVSR7()
{
const d = new Date();
if (d.getDay() == 0)
{
document.getElementById("PIET8").innerHTML = "Sunday";
}
else if (d.getDay() == 1)
{
document.getElementById("PIET8").innerHTML = "Monday";
}
else if (d.getDay() == 2)
{
document.getElementById("PIET8").innerHTML = "Tuesday";
}
else if (d.getDay() == 3)
{
document.getElementById("PIET8").innerHTML = "Wednesday";
}
else if (d.getDay() == 4)
{
document.getElementById("PIET8").innerHTML = "Thursday";
}
else if (d.getDay() == 5)
{
document.getElementById("PIET8").innerHTML = "Friday";
}
else if (d.getDay() == 6)
{
document.getElementById("PIET8").innerHTML = "Saturday";
}
}
</script>
<script>
function KVSR8()
{
const d = new Date();
document.getElementById("PIET9").innerHTML = d.getFullYear();
}
</script>
</body>
</html>