-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
842 lines (713 loc) · 27.2 KB
/
app.js
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
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
//--------------------------------------ChapterNo:01-----------------------------------------
// 1. Write a script to greet your website visitor using JS alert
// box.
// code:
// alert("Good Morning, jhon Doe!");
// 2. Write a script to display following message on your web
// page:
// Code
// alert("Error please enter a valid password!");
// 3. Write a script to display following message on your web
// page: (Hint : Use line break)
// code:
// alert("hi\ni am daniyalali");
// 4. Write a script to display following messages in sequence:
// 5. Generate the following message through browser’s
// developer console:
// code
// alert("Happy landing!");
// alert("Welcome to js");
// 6. Make use of alerts in your new/existing HTML & CSS
// project.
// code
// 7. Practice placement of <script></script> element in
// following sections of your project in exercise 6:
// a. Head
// b. Body (before your page’s HTML)
// ALERTS | JAVASCRIPT
// Page 3 of 3
// c. Body (inside your page’s HTML)
// d. Body (after your page’s HTML)
//--------------------------------------ChapterNo:02-----------------------------------------
// 1. Declare a variable called username.
// Code;
// var username;
//------------------------------------------------------------------------------------------
// 2. Declare a variable called myName & assign to it a string
// that represents your Full Name.
// code:
// var myName="Daniyal";
// var FullName="Daniyal Ali";
//----------------------------------------------------------------------------------------
// 3. Write script to
// a) Declare a JS variable, titled message.
// b) Assign “Hello World” to variable message
// c) Display the message in alert box.
// code:
// var title=alert("Hello World");
//--------------------------------------------------------------------------------------
// 4. Write a script to save student’s bio data in JS variables and
// show the data in alert boxes.
//
// code
// var myName=alert("my name is Daniyal Ali");
// var age=alert("i am 19 year old ");
// var certified=alert("Certified web and mobile developer:");
// Write a script to display the following alert using one JS variable:
// code
// alert("pizza\npizz\npiz\npi\np");
// 6. Declare a variable called email and assign to it a string that
// represents your Email Address(e.g. example@example.com).
// Show the blow mentioned message in an alert box.(Hint: use
// string concatenation)
// Code:
// alert("my email is dav.daniyalali@gamil.com");
// 7. Declare a variable called book & give it the value “A
// smarter way to learn JavaScript”. Display the following
// message in an alert box:
// Code:
// var message=alert("A smarter way to learn JavaScript");
// 8. Write a script to display this in browser through JS
// code
// document.write("what are you doing bro:");
// 9. Store following string in a variable and show in alert and
// browser through JS
// “▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬”
// code
// alert("▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬")
// //--------------------------------------ChapterNo:03-----------------------------------------
// 1. Declare a variable called age & assign to it your age. Show
//your age in an alert box.
// code
// var age =alert("I am 19 year Old:");
//---------------------------------------------------------------------------------------
// 2. Declare & initialize a variable to keep track of how many
// times a visitor has visited a web page. Show his/her
// number of visits on your web page. For example: “You
// have visited this site N times”.
// code
// var visitor=alert(" you are visited the website in 15 times:");
// --------------------------------------------------------------------------------------
// 3. Declare a variable called birthYear & assign to it your
// birth year. Show the following message in your browser:
// code
// var birthYear= 2003;
// document.write("My birth year is ", birthYear);
// var type=typeof(birthYear)
// document.write(" the data type of birthYear is : ", type);
//---------------------------------------------------------------------------------------
// 4. A visitor visits an online clothing store
// www.xyzClothing.com . Write a script to store in variables
// the following information:
// a. Visitor’s name
// b. Product title
// c. Quantity i.e. how many products a visitor wants to order.
// Show the following message in your browser: “John
// Doe ordered 5 T-shirt(s) on XYZ Clothing store”.
// code
// var Name="Jhon Doe";
// var tShirt= 10;
// var clothingStore="Abccl othing.com";
// document.write(Name + " "+ "Ordered" + " " + tShirt + "t-shirt" + " "+ "on" + " " + clothingStore);
//------------------------------chapter no : 04-----------------------------------------------
// 1. Declare 3 variables in one statement.
// code
// var variableOne=2; variableTwo=3; variableThree=5;
// console.log(variableOne , variableTwo, variableThree);
// 2. Declare 5 legal & 5 illegal variable names.
// code
// --------legal-----------
// var firstName=Daniyal;
// var _lastName=Ali;
// var $rollNo=first;
// var Gender=male;
// var Edu_cation=graduation;
// ---------illegal variable------
// var 1firstName=Daniyal;
// var -lastName=Ali;
// var ?rollNo=first;
// var Gen--der=male;
// var ++Edu_cation=graduation;
// 3. ---Display this in your browser---
// a) A heading stating “Rules for naming JS variables”
// b) Variable names can only contain , Number, string,
// underscore , dollarSign.
// For example $my_1stVariable
// c) Variables must begin with a _underscore_____, ___dollarSign___ or
// ___$_fistName__. For example $name, _name or name
// d) Variable names are "case _sensitive"
// e) Variable names should not be start with JS __Number__
// -----------------------------Chapter 5-----------------------------------------------------
// Write a program that take two numbers & add them in a
// new variable. Show the result in your browser
// code
// var a=4;
// var b=6;
// document.write("sum of " +" " + a + " + " + b + " = ",a+b);
// 2. Repeat task1 for subtraction, multiplication, division &
// modulus.
// code
// var a=4;
// var b=6;
// document.write("sum of " +" " + a + " + " + b + " = ",a+b);
// document.write(" ");
// document.write("sum of " +" " + a + " - " + b + " = ",a-b);
// document.write(" ");
// document.write("sum of " +" " + a + " * " + b + " = ",a*b);
// 3. Do the following using JS Mathematic Expressions
// a. Declare a variable.
// b. Show the value of variable in your browser like “Value
// after variable declaration is: ??”.
// c. Initialize the variable with some number.
// d. Show the value of variable in your browser like “Initial
// value: 5”.
// e. Increment the variable.
// f. Show the value of variable in your browser like “Value
// after increment is: 6”.
// g. Add 7 to the variable.
// h. Show the value of variable in your browser like “Value
// code:
// var variable=undefined;
// document.write(variable);
// var num1=7;
// var num2=13;
// var variable=5;
// document.write("initial value"+ " "+(variable) + "<br>");
// incrementValue =(++variable);
// document.write("value after increment" + incrementValue + "<br>");
// additionValue=document.write('Value after addition ' + (num1+incrementValue) + "<br>");
// decrementValue= --num2;
// document.write('Value after decrement ' + (decrementValue) + "<br>");
// document.write(variable+incrementValue);
// 4. Cost of one movie ticket is 600 PKR. Write a script to
// store ticket price in a variable & calculate the cost of buying 5 tickets
// to a movie. Example output:
// code:
// var totalTicket=5;
// ticketPrice=600;
// totalTicketPrice=totalTicket*ticketPrice;
// document.write("Total cost to buy"+ " " + totalTicket +" " + "tickets" + " " + " " + "is" + " " + totalTicketPrice + " " + "Pkr");
// 5. Write a script to display multiplication table of any
// number in your browser.
// code:
// n=5
// for(i=1;i<=10;i++){
// document.write(n + "X" + i + " = " + n*i + "<br>");
// }
// 6. The Temperature Converter: It’s hot out! Let’s make a
// converter based on the steps here.
// a. Store a Celsius temperature into a variable.
// b. Convert it to Fahrenheit & output “NNoC is NNoF”.
// c. Now store a Fahrenheit temperature into a variable.
// d. Convert it to Celsius & output “NNoF is NNoC”.
// var c=prompt("Enter a temperature in celsius");
// var f=prompt("Enter a temperature in fahrenheit");
// // celsius to Fahrenheit :
// celsius=(f-32)*5/9;
// fahrenheit=(c*9/5)+32;
// // Fahrenheit to celsius:
// console.log("The temperature of celsius to fahrenheit is",celsius);
// console.log("The temperature of fahrenheit to celsius is",fahrenheit);
// 7. Write a program to implement checkout process of a
// shopping cart system for an e-commerce website. Store
// the following in variables
// MATH EXPRESSIONS | JAVASCRIPT
// Page 5 of 9
// a. Price of item 1
// b. Price of item 2
// c. Ordered quantity of item 1
// d. Ordered Quantity of item 2
// e. Shipping charges
// Compute the total cost & show the receipt in your browserice of item 1
// code:
// var PriceItem1=(prompt("Enter a priceitem1:"));
// var orderedQuantityitem1=(prompt("Enter order quantity:"));
// var PriceItem2=(prompt("Enter a priceitem2:"));
// var orderedQuantityitem2=(prompt("Enter order quantity:"));
// document.write("PriceItem1 of is "+ PriceItem1+"<br>");
// document.write("Ordered quantity is "+ orderedQuantityitem1+"<br>");
// document.write("PriceItem2 of is "+ PriceItem2+"<br>");
// document.write("Ordered quantity is "+ orderedQuantityitem2+"<br>");
// document.write("totalcost is",(PriceItem1*orderedQuantityitem1+PriceItem2*orderedQuantityitem2));
// 8. Store total marks & marks obtained by a student in 2
// variables. Compute the percentage & show the result in your browser
// code:
// var subMarks1=+prompt("Enter A Subject marks number:");
// var subMarks2=+prompt("Enter A Subject marks number:");
// obtainMarks=subMarks1+subMarks2;
// totalMarks=200;
// document.write(obtainMarks/totalMarks*100+"%");
// 9. Assume we have 10 US dollars & 25 Saudi Riyals. Write a
// script to convert the total currency to Pakistani Rupees.
// Perform all calculations in a single expression.
// (Exchange rates : 1 US Dollar = 104.80 Pakistani Rupee
// and 1 Saudi Riyal = 28 Pakistani Rupee)
// var rupess=+prompt("Enter pakistani currency:")
// document.write(rupess+"pkr to dollar"+(rupess*177)+"<br>"+ rupess+" pkr to riyal "+(rupess*28)+"<br>");
// Write a program to initialize a variable with some
// number and do arithmetic in following sequence:
// code:
// var add=+prompt("add number");
// var sub=+prompt("subtract Number");
// var multiply=+prompt("multiply a number");
// total=add-sub*multiply;
// document.write(add+"-"+sub+"*"+multiply+" "+"="+total);
// 11. The Age Calculator: Forgot how old someone is?
// Calculate it!
// a. Store the current year in a variable.
// b. Store their birth year in a variable.ir
// c. Calculate their 2 possible ages based on the stored values.
// var birthYear=+prompt("Enter a BirthYear:");
// var currentYear=+prompt("Enter a currentYear:");
// age=currentYear-birthYear;
// document.write("BirthYear"+birthYear+"<br>");
// document.write("currentYear"+currentYear+"<br>");
// document.write("your age is ", age);
// 12. The Geometrizer: Calculate properties of a circle.
// a. Store a radius into a variable.
// MATH EXPRESSIONS | JAVASCRIPT
// Page 8 of 9
// b. Calculate the circumference based on the radius, and
// output “The circumference is NN”.
// (Hint : Circumference of a circle = 2 π r , π = 3.142)
// Calculate the area based on the radius, and output “The
// area is NN”. (Hint : Area of a circle = π r2, π = 3.142)
// code:
// var radius=+prompt("Enter a radius of circle:");
// document.write("Radius"+" "+radius+"<br>");
// coCircle=document.write("circumference of circle is"+2*3.14*radius+"<br>");
// areaCircle=document.write("Radius of circle is"+3.14*(radius*radius));
// 13. The Lifetime Supply Calculator: Ever wonder how
// much a “lifetime supply” of your favorite snack is?
// Wonder no more.
// a. Store your favorite snack into a variable
// b. Store your current age into a variable.
// c. Store a maximum age into a variable.
// d. Store an estimated amount per day (as a number).
// e. Calculate how many would you eat total for the rest of
// your life.
// var age=15;
// var maxAge=65;
// var TotalamountSnackperday=3;
// var totalNeeded = (TotalamountSnackperday * 365) * (maxAge - age);
// var message = 'You will need ' + totalNeeded + ' chocolate chip to last you until the ripe old age of ' + maxAge;
// document.write(message);
// -------------------------Chapter 6 to 9-------------------------------------
// Write a program to take a number in a variable, do the
// required arithmetic to display the following result in your
// browser:
// code
// var a=10;
// document.write(++a + a++ + --a - a--);
// 2. What will be the output in variables a, b & result after
// execution of the following script:
// var a = 2, b = 1;
// var result = --a - --b + ++b + b--;
// Explain the output at each stage:
// --a; = 1
// --a - --b; 1 - 0
// --a - --b + ++b; 1 - 0 + 1
// --a - --b + ++b + b-- = 1 - 0 +1 +1 = 3
// a=2
// b=1
// manually Exceution;
// --a - --b + ++b + b--
// 1 - 0 + 1 + 1 = 3
// Document.write(--a - --b + ++b + b--);
// 3. Write a program that takes input a name from user &
// greet the user.
// code
// var userName=prompt("Enter a name");
// document.write(userName + " " + "good Morning");
// // 4.
// 5. Write a program to take input a number from user &
// display it’s multiplication table on your browser. If user
// does not enter a new number, multiplication table of 5
// should be displayed by default.
// nhy ho raha ye wala
// 6. Take
// a) Take three subjects name from user and store them in 3
// different variables.
// Part:A
// code
// var user1=prompt("Enter your subject name");
// var user2=prompt("Enter your subject name");
// var user3=prompt("Enter your subjects name");
// b) Total marks for each subject is 100, store it in another
// variable.
// Part:B
// code
// totalMarks=100;
// c) Take obtained marks for first subject from user and
// stored it in different variable.
// Part:C
// code
// var user1=+prompt("Enter you first subject marks:");
// Part:B
// code
// totalMarks=300;
// Part:C
// code
// var firstSubject=+prompt("Enter you first subject marks:");
// d) Take obtained marks for remaining 2 subjects from user
// and store them in variables.
// code
// var user2=+prompt("Enter your marks");
// var user3=+prompt("Enter you marks");
// e) Now calculate total marks and percentage and show the
// result in browser like this.(Hint: user table)
// code
// obtainMArks=('total obtain marks user2' , user1+user2+user3);
// document.write('total obtain marks',obtainMArks);
// ----------percentage---------------------------
// percentage = (obtainMArks)/totalMarks*100;
// document.write("percentage =",percentage);
// -------------------------------Chapter (9 to 11)----------------------------------------
// 1. Write a program to take “city” name as input from user. If
// user enters “Karachi”, welcome the user like this:
// “Welcome to city of lights”
// code
// var city=prompt("Enter City Name:")
// if(city == "karachi"){
// console.log("“Welcome to city of lights”")
// }
// else{
// console.log("Invalid!city name")
// }
// 2. Write a program to take “gender” as input from user. If the
// user is male, give the message: Good Morning Sir. If the
// user is female, give the message: Good Morning Ma’am.
// code
// var gender=prompt("Enter You Gender:");
// if(gender=="male"){
// console.log("Good Morning Sir");
// }
// else if(gender == "female"){
// console.log("Good Morning Ma’am");
// }
// else{
// console.log("Invalid! gender.")
// }
// 3. Write a program to take input color of road traffic signal
// from the user & show the message according to this table:
// Signal color Message
// Red Must Stop
// Yellow Ready to move
// Green Move now
// code
// var trafficSignal = prompt("Enter road traffic signal color :");
// if (trafficSignal == "red") {
// console.log("Red Must Stop");
// } else if (trafficSignal == "yellow") {
// console.log("Yellow Ready to move");
// }
// else if (trafficSignal == "green") {
// console.log(" Green Move now");
// }
// else{
// console.log("Invalid traffic Signal colors");
// }
// 4. Write a program to take input remaining fuel in car (in
// litres) from user. If the current fuel is less than 0.25litres,
// show the message “Please refill the fuel in your
// code
// var currentFuel = +prompt("Enter remaining fuel in car (in litres) :");
// if(currentFuel < 0.25){
// console.log("Please refill the fuel.");
// }
// else{
// console.log("Fuel Tank is full.");
// }
// 5. Run this script, & check whether alert message would be
// displayed or not. Record the outputs.
// var a = 4;
// if (++a === 5){
// alert("given condition for variable a is true");
// }
// the message is displayed(given condition for variable a is true)
// var b = 82;
// if (b++ === 83){
// alert("given condition for variable b is true");
// }
// wrong progra
// var c = 12;
// if (c++ === 13){
// alert("condition 1 is true");
// }
// if (c === 13){
// alert("condition 2 is true");
// }
// if (++c < 14){
// alert("condition 3 is true");
// }
// if(c === 14){
// alert("condition 4 is true");
// }
// var materialCost = 20000;
// var laborCost = 2000;
// var totalCost = materialCost + laborCost;
// if (totalCost === laborCost + materialCost){
// alert("The cost equals");
// }
// if("car" < "cat"){
// alert("car is smaller than cat");
// }
// right answer car is smaller than cat
// 6. Write a program to take input the marks obtained in three
// subjects & total marks. Compute & show the resulting
// percentage on your page. Take percentage & compute
// grade as per following table:
// Show the total marks, marks obtained, percentage, grade &
// remarks like:
// code:
// var sub1=+prompt("Enter your Math Marks:");
// var sub2=+prompt("Enter your English Marks:");
// var sub3=+prompt("Enter your Urdu Marks:");
// var sub4=+prompt("Enter your Computer Marks:");
// var sub5=+prompt("Enter your Physics Marks:");
// totalMarks=500;
// console.log("totalMarks=500")
// // obtain marks
// obtainMarks=(sub1+sub2+sub3+sub4+sub5);
// console.log('Obtain marks is',obtainMarks);
// // calculate the percentage
// per=(obtainMarks/totalMarks*100);
// console.log("The total percentage is",per);
// // Grade
// if(per>=80 && per<=100){
// console.log("your percentage is A+")
// console.log("Remarks: Excellent");
// }
// else if(per>=70 && per<=79){
// console.log("your percentage is A")
// console.log("Remarks: Good");
// }
// else if(per>=60 && per<=69){
// console.log("your percentage is B");
// console.log("Remarks: Nice");
// }
// else if(per>=50 && per<=59){
// console.log("your percentage is C");
// console.log("Remarks: keep it up");
// }
// else if(per>=40 && per<=49){
// console.log("your percentage is D")
// console.log("Remarks: keep it up");
// }
// else if(per>=0 && per<=39){
// console.log("your are fail");
// }
// else{
// ('invalid percentage');
// console.log("Remarks: Looser");
// }
// 7.Guess game:
// Store a secret number (ranging from 1 to 10) in a variable.
// Prompt user to guess the secret number.
// a. If user guesses the same number, show “Bingo! Correct
// answer”.
// secretNumber=6;
// var guessNumber=+prompt("Guessing number win price:(ranging from 1 to 10)");
// if(guessNumber==secretNumber){
// console.log("Bingo! Correct");
// }
// else{
// console.log("Invalid!city name");
// }
// b. If the guessed number +1 is the secret number, show
// “Close enough to the correct answer”.
// code
// secretNumber=1;
// var guessNumber=+prompt("Guessing number win price:(ranging from 1 to 10)");
// if(guessNumber == secretNumber){
// console.log(" Correct answer");
// }
// else if( guessNumber>=2 && guessNumber <=5 ){
// console.log("Close enough but your number to high please choose the low number:");
// }
// else if( guessNumber>=6 && guessNumber <=10 ){
// console.log("Close enough but your number very very high please choose the low number:");
// }
// else{
// console.log("Invalid!city number ");
// }
// 8. Write a program to check whether the given number is
// divisible by 3. Show the message to the user if the number
// is divisible by 3.
// var number=+prompt("check the number is divisible by 3");
// if(number%3 == 0){
// console.log("the number is divisible by 3");
// }
// else{
// console.log("the number is not.. divisible by 3");
// }
// 9. Write a program that checks whether the given input is an
// even number or an odd number.
// var checkNum=+prompt("check the number is even or odd:");
// if(checkNum%2 == 0){
// console.log("The number is even..")
// }
// else{
// console.log("The number is Odd..");
// }
// 10. Write a program that takes temperature as input and
// shows a message based on following criteria
// a. T > 40 then “It is too hot outside.”
// b. T > 30 then “The Weather today is Normal.”
// c. T > 20 then “Today’s Weather is cool.”
// d. T > 10 then “OMG! Today’s weather is so Cool.”
// var checkTemp=+prompt("check the temperature:");
// if(checkTemp > 40 && checkTemp <= 60 ){
// console.log("It is too hot outside");
// }
// else if(checkTemp > 30 && checkTemp <= 40 ){
// console.log("The Weather today is Normal");
// }
// else if(checkTemp > 20 && checkTemp <= 30 ){
// console.log("Today’s Weather is cool");
// }
// else if(checkTemp > 10 && checkTemp <= 20 ){
// console.log("OMG! Today’s weather is so Cool");
// }
// else{
// console.log("Invalid ");
// }
// 11. Write a program to create a calculator for +,-,*, / & %
// using if statements. Take the following input:
// a. First number
// b. Second number
// c. Operation (+, -, *, /, %)
// Compute & show the calculated result to user.
// var num1=+prompt("Enter a first number:");
// var num2=+prompt("Enter a Second number:");
// var operator=prompt("Enter operator (+,-,*, / & %)");
// if (operator == "+"){
// console.log(num1 + "+" + num2 + "=",num1+num2);
// }
// else if (operator == "-"){
// console.log(num1 + "-" + num2 + "=",num1-num2);
// }
// else if (operator == "/"){
// console.log(num1 + "/" + num2 + "=",num1/num2);
// }
// else if (operator == "*"){
// console.log(num1 + "+" + num2 + "=",num1-num2);
// }
// else if (operator == "%"){
// console.log(num1 + "%" + num2 + "=",num1%num2);
// }
// else{
// console.log("Invalid operation");
// }
// -------------------------------------------------chapter:12-13----------------------------------------------------------------------
// 1. Write a program that takes a character (number or string)
// in a variable & checks whether the given input is a
// number, uppercase letter or lower case letter. (Hint: ASCII
// codes:- A=65, Z=90, a=97, z=122).
// code:
// var user = prompt(" a word check upercase or lowercase:")
// if((user>="A" || user>="65") && (user<="Z" || user<="90")){
// document.write("the letter is uppercase",user)
// }
// else if((user>="a" || user>="96") && (user<="z" || user<="122")){
// document.write("the letter is lowercase",user)
// }
// else{
// document.write("invalid statement:")
// }
// 2. Write a JavaScript program that accept two integers and
// display the larger. Also show if the two integers are equal.
// code :
// document.write("display a large number or equal number on screen <br>");
// user1 = +prompt("Enter a number:");
// user2 = +prompt("Enter a number:");
// if (user1 >= user2) {
// document.write(user1 + "is greater than" + user2)
// }
// else if(user2>=user1){
// document.write(user1 + "is lesser than" + user2)
// }
// else{
// document.write("invalid statement:")
// }
// 3. Write a program that takes input a number from user &
// state whether the number is positive, negative or zero.
// var user=+prompt("check the number is +positive -negative or zero: ")
// if(user>0){
// document.write("number is positive:")
// }
// else if(user == 0){
// document.write("the number is zero:")
// }
// else if(user<0){
// document.write("number is negative:")
// }
// else{
// document.write("invalid statement")
// }
// 4. Write a program that takes a character (i.e. string of
// length 1) and returns true if it is a vowel, false otherwise
// var user =prompt("check the word is vowel or not:")
// if(user == 'a' || user == 'e' || user == 'i' || user == 'o' || user == 'u'){
// document.write("the character is vowel..")
// }
// else if(user == 'A' || user == 'E' || user == 'I' || user == 'O' || user == 'U'){
// document.write("the character is vowel..")
// }
// else{
// document.write("the character is ..NOT.. vowel")
// }
// 5. Write a program that
// a. Store correct password in a JS variable.
// b. Asks user to enter his/her password
// c. Validate the two passwords:
// i. Check if user has entered password. If not, then
// give message “ Please enter your password”
// ii. Check if both passwords are same. If they are
// same, show message “Correct! The password you
// entered matches the original password”. Show
// “Incorrect password” otherwise.
// var savePassword=123456
// var user=+prompt("Enter a password:")
// if(user == savePassword){
// document.write("correct!")
// }
// else{
// document.write('Please enter your correct password')
// }
// 6. This if/else statement does not work. Try to fix it:
// var greeting;
// var hour = 13;
// if (hour < 18) {
// greeting = "Good day";
// else
// greeting = "Good evening";
// }
// code:
// var user=prompt("Enter a hour")
// if (user < 18){
// document.write("Good day")
// }
// else{
// document.write("Good evening")
// }
// 7. Write a program that takes time as input from user in 24
// hours clock format like: 1900 = 7pm. Implement the
// following case using if, else & else if statements
// code:
// var user = +prompt("Enter a time hour");
// if ((user >= 0000 && user< 1200)) {
// document.write("Good Morning");
// } else if (user >= 1200 && user < 1700) {
// document.write("Good Afternoon");
// } else if (user >= 1700 && user < 2100) {
// document.write("Good Evening");
// } else if (user >= 2100 && user < 2359) {
// document.write("Good Morning");
// } else {
// document.write("invalid statement");
// }
let reverseArr = "daniyal";
for(i=reverseArr.length; i>=0; i--){
print(reverseArr[i]);
}