-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
604 lines (386 loc) · 10.9 KB
/
app.js
File metadata and controls
604 lines (386 loc) · 10.9 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
// chapter 1
// alert("FirstNAME" + " SHAHMEER");
// alert("LasttNAME" + " NADEEM");
// alert("Email" + " shah.khan.5757@gmail.com");
// alert("Number" + " 0333-2569366");
// alert("Password" + " kkokoko");
// Correct this statement: alert"You're learning JavaScript!";
// alert("You're Learning Javascript");
// Code an alert statement displaying any message you like.
// alert("Welcome to this Page");
// chapter 2
// var someVar;
// var str;
// var str = "Hello there";
// alert(str);
// var TeamName = " KARACHI KINGS"
// alert("TeamName is" + TeamName);
// var bestMan = "AMIR";
// var bestMan = "BABAR";
// alert(bestMan)
//CHAPTER 3://
// var caseQty = 144;
// var num = +"9";
// var sum;
// var sum = caseQty + num;
// alert(sum);
// var merchTotal = 100;
// var shippingCharge = 10;
// var orderTotal = merchTotal + shippingCharge;
// alert(orderTotal); //ANSWER IS 110;
// var a = 15;
// var b = a + 29;
// alert(b);
// chapter 4
// var productcost = 3.45;
// var Nameofband = "SomeBandName";
// var camelCaseName = Nameofband.charAt(0).toLowerCase() + Nameofband.slice(1);
// console.log("Camel case name:", camelCaseName);
// var legalvar2 = 45;
// console.log(legalvar2);
// var fname = "shahmeer"
// var Lstname = " nadeem"
// var combname = fname + Lstname;
// console.log(combname);
// Examples of legal variable names:
// var myVariable;
// var _privateVar;
// var myVar2;
// var firstName;
// Examples of illegal variable names:
// var 123abc;
// var my variable;
// var if;
//CHAPTER 5://
// q1
// What is the name and symbol of the arithmetic operator that
// gives you the remainder when one number is divided by another?
// ANSWER IS MODULO OPERATOR. (abbreviated as mod).
// What is the value of num?
// var num = 20 % 6;
// console.log(num); //ANSWER IS 2;
// var largeNum = 1000 * 2000;
// console.log(largeNum);
// var a = 4;
// var b = a;
// var c = 2;
// var d = c;
// var res = b - d;
// console.log(res);
// const dividend = 10;
// const divisor = 3;
// const remainder = dividend % divisor;
// console.log(remainder);
// var a = 3;
// var b = 12;
// var c = a * b;
// alert(c);
// chapter 6
// q1
// var x = 5;
// x += 1;
// console.log("New value of x:", x);
// q2
// var x = 100;
// x -= 1;
// console.log("New value of x:", x);
// q4
// var y = 50;
// var z = --y;
// console.log("Value of y:", y);
// console.log("Value of z:", z);
// q5
// var num = 10;
// var newNum = num--;
// console.log("Value of num:", num);
// console.log("Value of newNum:", newNum);
// q6
// var num = 10;
// var newNum = num++;
// console.log("Value of num:", num);
// console.log("Value of newNum:", newNum);
// q7
// var num = 5;
// num++;
// alert("New value: " + num);
// chapter 07
// q1
// var calculatedNum = 2 + (2 * 6);
// console.log(calculatedNum)
// q2
// var calculatedNum = (2 + 2) * 6;
// console.log(calculatedNum)
// q3
// var calculatedNum = (2 + 2) * (4 + 2);
// console.log(calculatedNum)
// q4
// var calculatedNum = ((2 + 2) * 4) + 2;
// console.log(calculatedNum)
// q5
// var cost = (2 + (2 * 4) + 10);
// console.log(cost);
// q6
// var units = ((2 + 2) * 4) + 10;
// console.log("Units:", units);
// q7
// var pressure = (4 / 2) * 4;
// console.log(pressure);
// chapter08
// q1
// var num = "2" + "2";
// What is the value of num? Include quotation marks.
// q2
// var message = ("Hello," + "Dolly");
// alert(message);
// q3
// alert("33" + 3);
// q4
// var PAK = "Pakistan";
// var ZIN = "Zindabad";
// alert(PAK + ZIN);
// q5
// var hlo = "Hello" + 123;
// q6
// var a = "SHAH"
// var b = "MEER"
// var result = console.log(a+b)
// chapter 9
// var firstName = prompt("Enter First Name");
// var Country = prompt("Counrty?", "China")
// Correct this statement
// var yourName = prompt(Enter Your Name");
// var yourName = prompt("Enter Your Name");
// var str = prompt("Welcome", "Write something");
// var a = "Vini";
// var b = "jr";
// var c = prompt(a, b);
// var d = prompt("Enter a string");
// var e = d;
// console.log(e);
// var message = prompt("How are you?", "Good");
// alert(message);
// chapter 10
// q1
// var city = "Karachi"
// if (city = "Karachi") {
// console.log("The City OF Lights")
// }
// q2
// if (x === y) {
// var x = "05"
// var y = "06"
// var z = "096"
// }
// var z = prompt("Please enter the value of z:");
// q3
// if (ZipCode = "10010") {
// var ZipCode = "10010"
// var City = prompt("enter zipcode")
// alert("Karachi");
// } else {
// alert("Please write correct city");
// }
// q4
// if (x === 1) {
// var x = 10;
// }
// else{
// alert("value of x is 10")
// }
// Chapter 11 (Comparison Operators)
// 1. Code the first line of an if statement that tests whether one
// variable is unequal to another. (Use !)
// if (variable1 !== variable2) {
// // Code to be executed if the condition is true
// }
// 2. Code the first line of an if statement that tests whether the
// value represented by a variable is greater than or equal to the
// value represented by another variable.
// if (variable1 >= variable2) {}
// 3. Code an if statement. Test whether a variable is unequal to a
// particular number. If so, assign a number to that variable.
// if (variable !== 40) {
// variable = 10;
// }
// Chapter 12 (if...else and else if statements)
// var a = +prompt("Enter Num");
// if (a <= 20) {
// alert("if statment")
// }
// else if(a <= 50)
// alert("else if statment")
// else {
// alert("else statment")
// }
// 2. Write a program using if else and else if statement which take
// marks from user. And the program will calculate your percentage
// and give you grade A/C to Your percentage. (MARKSHEET)
// var marks = +prompt("Enter your marks:");
// var percentage = (marks / 100) * 100;
// var grade;
// if (percentage >= 90) {
// grade = "A";
// } else if (percentage >= 80) {
// grade = "B";
// } else if (percentage >= 70) {
// grade = "C";
// } else if (percentage >= 60) {
// grade = "D";
// } else {
// grade = "F";
// }
// console.log("Percentage: " + percentage + "%");
// console.log("Grade: " + grade);
// 3. This is the if statement that begins the code.
// if (a === 10) {
// alert("a is 10");
// }
// If a isn't 10, display an alert that says The correct value of a is
// if (a === 10) {
// alert("a is 10");
// }
// else{
// alert("The correct value of a is 10");
// }
// Chapter 13 (Testing sets of conditions)
// var a = 10;
// var b = 10;
// var c = 20;
// var d = 20;
// if (a === b && c === d) {
// alert("True")
// }
// else{
// alert("False")
// }
// 2. Code the first line of an if statement that tests whether either or
// both are true: a has the same value as b or c doesn't have the
// same value as d.
// var a = 10;
// var b = 15;
// var c = 20;
// var d = 25;
// if (a === b || c !== d) {
// alert("True")
// }
// else{
// alert("False")
// }
// 3. Code the first line of an if statement that tests whether
// I. name is either "Hamza" or "Arsalan".
// II. age is Less than 60.
// var name = prompt("Enter Name")
// if (name === "Hamza" || name === "Arsalan") {
// alert("welcome "+ name);
// }
// var age = +prompt("Enter Age")
// if (age < 60) {
// alert("Your Age is "+ age)
// }
// Chapter 14 (If statements nested)
// 1. Code an if statement enclosing a nested if. If password is not
// empty, then check if password is not greater than 5 , then display
// an alert that says "Password must be greater than 5" if greater
// than 5 then Alert "OK".
// if (password !== "") {
// if (password.length <= 5) {
// alert("Password must be greater than 5.");
// } else {
// alert("OK");
// }
// }
// 2. Try this statement by yourself
// if (a === 1) {
// if (c === "Max") {
// alert("OK");
// }
// }
// var a = 1;
// if (a === 1) {
// var c = "Max";
// if (c === "Max") {
// alert("OK");
// }
// }
// 4. Declare two variables and assign them the same number value.
// Test two conditions, using nested if statements. Test whether the
// first variable equals the second variable and also whether it is less
// than or equal to the second variable. If the test passes—and it
// will—display an alert message.
// var a1 = 5;
// var a2 = 5;
// if (a1 === a2) {
// if (a1 <= a2) {
// alert("The conditions passed!");
// }
// }
// Chapter 15 (Array I)
// 1. Declare an empty array.
// var a = [];
// 2. Code an array with 1 string element
// var myArray = ["Hello"];
// 3. var alphabet = ["h","i","j","k"]. Now print the letter “j” in alert
// using array index
// var alphabet = ["h", "i", "j", "k"];
// alert(alphabet[2]); // Output: "j"
// 4. var alphabet=["h","i","j","k", “l”,”m”, “n”, “o”]. Find the total
// length of array.
// var alphabet = ["h", "i", "j", "k", "l", "m", "n", "o"];
// var length = alphabet.length;
// alert(length); // Output: 8
// Chapter 16 (Array II)
// 1. Code an array with 1 string element.
// Add an additional element to the array using push.
// var arr = ["string"];
// arr.push("string2");
// alert(arr);
// 2. var Alphabet=["h","i","j","k"]
// Remove the last element from the array Alphabet.
// var Alphabet = ["h", "i", "j", "k"];
// Alphabet.pop();
// 3. var Alphabet=["h","i","j","k"]
// Add a new element, a number, to the end of an array.
// var Alphabet = ["h", "i", "j", "k"];
// Alphabet.push(5);
// Chapter 16 (Array III)
// 1. var sizes = ["S", "M", "XL", "XXL", "XXXL"].
// Remove the first element of an array.
// var sizes = ["S", "M", "XL", "XXL", "XXXL"];
// sizes.shift();
// 2. var sizes = ["S", "M", "XL", "XXL", "XXXL"].
// Add three number elements to the beginning of an array.
// var sizes = ["S", "M", "XL", "XXL", "XXXL"];
// sizes.unshift(1, 2, 3);
// 3. Declare an array with one element.
// Add a second element to the beginning of the array.
// Create an alert whose message is the new first element.
// var arr = [1];
// arr.unshift(2);
// alert(arr[0]);
// 4. var sizes = ["S", "M", "XL", "XXL", "XXXL"].
// Insert "L" into the array between "M" and "XL".
// var sizes = ["S", "M", "XL", "XXL", "XXXL"];
// sizes.splice(2, 0, "L");
// Chapter 17 - 20 (for Loops)
// 1. Write a statement in which loop is to run 10 times.
// for (var i = 0; i <=9; i++) {
// console.log(i) //Output is 10
// }
// 2. Code the first line of a for loop with the usual counter name, usual
// starting value, and usual increment. Run it 12 times using <= to
// specify how many loops.
// for (var i = 0; i <=11; i++) {
// console.log(i) //Output is 12
// }
// 3. What are the 5 characters missing from this code, excluding any
// spaces that are missing? Type them in order, with no spaces or
// commas between them.
// for var i = 0 i <= 4 i++
// for (var i = 0; i <= 4; i++){
// }
// 5. Code the first line of a for loop with the usual counter and the
// usual starting value. Run it 3 times using > to specify how many
// loops. Decrement it with each iteration.
// for (var i = 3; i > 0; i--) {
// console.log(i);
// }