-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
271 lines (234 loc) · 6.24 KB
/
index.js
File metadata and controls
271 lines (234 loc) · 6.24 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
console.log("Hello");
window.alert("Success !")
let firstName = "tharindu";
// let age = 22 ;
// let drive = true;
//
// console.log(firstName)
// console.log(age)
// console.log(drive)
//
// document.getElementById("p1").innerHTML = "Hello " + firstName;
// document.getElementById("p2").innerHTML = "Age " + age;
// document.getElementById("p3").innerHTML = "Drive " + drive;
// Arithmatic expression
// let students = 20;
//
// students = students + 1;
// students = students - 1;
// students = students * 1;
// students = students / 1;
// students = students % 1;
//
// students += 1;
// students -= 1;
// students *= 2;
// students /= 2;
// students %= 3;
//
// let result = 5 + 5 * (3+4);
// console.log(result);
//User Input
// let userName = window.prompt("Your Name ?");
// console.log(userName);
// let userName;
//
// document.getElementById("btn").onclick = function (){
// userName = document.getElementById("my").value;
// console.log(userName);
// document.getElementById("myLabel").innerHTML = "Hello "+userName;
// }
//Type Conversion
// let age = window.prompt("How old are u?")
// console.log(typeof age);
// age = Number(age);
// console.log(typeof age);
//
// console.log("Happy " + age + " Birthday !")
// let x = Number("2.55");
// let y = String("2.55");
// let z = Boolean("AAA");
//
// console.log(x, typeof x);
// console.log(y, typeof y);
// console.log(z, typeof z);
//Const
// const height = 50;
// let width;
//
// width = window.prompt("Enter width :");
// let area = height * width;
// console.log("Area : " + area);
//hypotenuse
// document.getElementById("btn").onclick = function (){
// let a = document.getElementById("sideA").value;
// a = Number(a);
// let b = document.getElementById("sideB").value;
// b = Number(b);
//
// let c = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2 ));
//
// document.getElementById("cLable").innerHTML = "C : " + c;
// }
//Countdown
//
// let count = 0;
//
// document.getElementById('decrease').onclick = function () {
// count-=1;
// document.getElementById("count").innerHTML = count;
// }
// document.getElementById('reset').onclick = function () {
// count =0;
// document.getElementById("count").innerHTML = count;
// }
// document.getElementById('increase').onclick = function () {
// count+=1;
// document.getElementById("count").innerHTML = count;
// }
//Raandom
// let x;
// let y;
// let z;
//
// document.getElementById("roll").onclick = function () {
// x = Math.floor(Math.random()*6)+1;
// y = Math.floor(Math.random()*6)+1;
// z = Math.floor(Math.random()*6)+1;
//
// document.getElementById("xx").innerHTML = x;
// document.getElementById("yy").innerHTML = y;
// document.getElementById("zz").innerHTML = z;
// }
// let fullName = "tharindu dasun";
// let firstname ;
// let lastname ;
//
// firstname = fullName.slice(0,fullName.indexOf(""));
// lastname = fullName.slice(0,fullName.indexOf(""));
//
// console.log(firstname);
// console.log(lastname);
// document.getElementById("btn").onclick = function () {
// if (document.getElementById("checkbox").checked){
// console.log("Hari");
// }else {
// console.log("Hari na");
// }
// }
// document.getElementById("submit").onclick = function () {
//
// const visaRadio = document.getElementById("visaRadio");
// const masterRadio = document.getElementById("masterRadio");
// const paypalRadio = document.getElementById("paypalRadio");
//
// if (visaRadio.checked){
// console.log("Visa pay");
// }else if (masterRadio.checked){
// console.log("Master pay");
// }else if (paypalRadio.checked){
// console.log("Paypal pay");
// }else {
// console.log("Select Payment");
// }
// }
// Nested loop
// let rows = window.prompt("Rows :");
// let colums = window.prompt("Colums :");
//
// for ( let i = 1 ; i<=rows ; i+=1){
// for (let j =1; j<=colums ; j+=1){
// document.getElementById("kotuwa").innerHTML +=j;
// }
// document.getElementById("kotuwa").innerHTML += "<br>";
// }
// start();
//
// function start(){
// let name = "kasun";
// let age = 22;
//
// birthday( name , age);
// }
//
// function birthday( name , age ) {
// console.log("Happy Birthday to you ...!");
// console.log("Happy Birthday to you ...!");
// console.log("Happy Birthday dear " , name , "...!");
// console.log("Happy " , age , " Birthday to you ...!");
// }
// let width = window.prompt("Enter Width :");
// let height = window.prompt(" Enter height :");
// let area;
//
// area = getArea(width, height);
//
// console.log("Area : " , area);
//
// function getArea( width, height) {
// return width * height;
// }
// checkWinner(true);
//
// function checkWinner(win){
// win ? console.log("You Win !") : console.log("You lose !")
// }
// let userName = "Kasun";
// let items = 3;
// let total = 150;
//
// let text = `hello ${userName} , your have ${items} total items , and your total price is $ ${total}`
//
// document.getElementById("total").innerHTML = text;
//
// document.getElementById("submit").onclick = function (){
// let temp ;
// if (document.getElementById("cradio").checked){
//
// }else if (document.getElementById("fradio").checked){
//
// }
// }
//Arrays
// let fruits = ["apple" , "banana" , "mango"];
//
// fruits.push("lemon");
// console.log(fruits);
// console.log(fruits[0]);
//
// fruits.pop();
// fruits.unshift("bbbb")
// fruits.shift();
//
// let length = fruits.length;
// console.log(length);
// let fruits = ["apple" , "banana" , "mango" , "zer"];
//
// // fruits = fruits.sort();
// fruits = fruits.sort().reverse();
//
// for (let fruit of fruits){
// console.log(fruit);
// }
//Spread operator
// let class1 = ["A" , "B" , "C"];
// let class2 = ["D" , "E" , "F"];
//
// class1.push(...class2);
// console.log(class1);
//Array.forEach()
// let Students = ["kasun" , "nimal" , "dasun"];
// students.forEach(capitalize());
// students.forEach(print());
//
// function capitalize(element, index, array) {
// array[index] = element[0].toUpperCase()+element.substring(1);
// }
//
// function print(element){
// console.log(element)
// }
let e = document.getElementById('btn');
e.addEventListener('click',function (){
alert('button clicked !')
});