1+ let studentNames = [ ]
2+ let students = new Array ( )
3+
4+ let string_array = [ 'mudassir' , 'hadi' ]
5+ let number_array = [ 10 , 20 ]
6+ let boolean_array = [ true , false ]
7+ let mixed_array = [ 'mudassir' , 20 , true ]
8+
9+ let qualifications = [ ' 1) SSC <br>' + '2) HSC <br>' + '3) BCS <br>' + '4) BS <br>' + '5) BCOM <br>' + '6) MS <br>' + '7) M. Phil. <br>' + '8) PhD <br>' ]
10+ document . write ( '<font size=5> Qualifications: <br> <br>' + qualifications + '<br> <br>' )
11+
12+ let students_Names = [ 'Michael' , 'John' , 'Tony' ]
13+ let students_scores = [ 320 , 230 , 480 ]
14+
15+ document . write ( 'Score of ' + students_Names [ 0 ] + ' ' + 'is ' + students_scores [ 0 ] + '.' + 'Percentage is ' + students_scores [ 0 ] / 500 * 100 + '% <br>' )
16+ document . write ( 'Score of ' + students_Names [ 1 ] + ' ' + 'is ' + students_scores [ 1 ] + '.' + 'Percentage is ' + students_scores [ 1 ] / 500 * 100 + '% <br>' )
17+ document . write ( 'Score of ' + students_Names [ 2 ] + ' ' + 'is ' + students_scores [ 2 ] + '.' + 'Percentage is ' + students_scores [ 2 ] / 500 * 100 + '% <br> <br>' )
18+
19+ let color = [ 'red' , 'green' ]
20+ let color_asking = prompt ( 'Enter any color you want to add in the beginning' )
21+ let color_asking2 = prompt ( 'Enter any color you want to add in the end' )
22+
23+ color . unshift ( color_asking )
24+ document . write ( 'Adding user color in the beginning of the array:' + color + '<br>' )
25+
26+ color . push ( color_asking2 )
27+ document . write ( 'Adding user color in the end of the array:' + color + '<br>' )
28+
29+ color . unshift ( 'blue' , 'pink' )
30+ document . write ( 'Adding two color in the beginning of the array:' + color + '<br>' )
31+
32+ color . shift ( )
33+ document . write ( 'Deleting the first color in the array:' + color + '<br>' )
34+
35+ color . pop ( )
36+ document . write ( 'Deleting the last color in the array:' + color + '<br>' )
37+
38+
39+ let index_asking = prompt ( 'Enter at what position/index you want to add the color' )
40+ let color_asking_name = prompt ( 'Enter the color name you want to add at ' + index_asking + ' position' )
41+
42+ color [ index_asking ] = [ color_asking_name ]
43+ document . write ( 'Adding color at specific index by asking user:' + color + '<br>' )
44+
45+ let color_count = prompt ( 'How many colors you want to delete' )
46+
47+ for ( let index = 0 ; index < color_count ; index ++ ) {
48+ let index_asking2 = prompt ( 'Enter at what position/index you want to delete the color' )
49+ color [ index_asking2 ] = [ ]
50+ document . write ( 'Deleting color at specific index by asking user:' + color )
51+ }
52+
53+ let numbers = [ 320 , 230 , 480 , 120 ]
54+ document . write ( 'Scores of Students : ' + numbers + '<br>' )
55+
56+ numbers . sort ( function ( a , b ) {
57+ return a - b ;
58+ } ) ;
59+ document . write ( 'Ordered Scores of Students : ' + numbers , '<br> <br>' ) ;
60+
61+
62+ document . write ( 'Cities list: <br>' )
63+ let cities = [ 'Karachi' , 'Lahore' , 'Islamabad' , 'Quetta' , 'Peshawar <br> <br>' ]
64+ document . write ( cities )
65+
66+ document . write ( 'Selected cities list <br>' )
67+ let selectedCities = [ 'Islamabad' , 'Quetta' , 'Peshawar <br> <br>' ]
68+ document . write ( selectedCities )
69+
70+ var arr = [ 'This' , 'is' , 'my' , 'cat' ] ;
71+ document . write ( 'Array: <br> ' + arr + '<br> <br>' )
72+
73+ var joining_arr = arr . join ( ' ' ) ;
74+ document . write ( 'Array: <br> ' + joining_arr + '<br> <br>' )
75+
76+ let devices = [ 'keyboard' , 'mouse' , 'printer' , 'moniter' ]
77+ document . write ( 'Devices: <br>' + devices + '<br>' )
78+
79+ document . write ( devices + '<br> <br>' )
80+
81+ let devices2 = [ 'keyboard' , 'mouse' , 'printer' , 'moniter' ]
82+ document . write ( 'Devices: <br>' + devices + '<br>' )
83+
84+ let devices_reverse = devices2 . reverse ( ) ;
85+ document . write ( devices_reverse + '<br> <br>' )
86+
87+ let phone_manufacturers = [ 'Apple <br>' + 'Samsung <br>' + 'Motorola <br>' + 'Nokia <br>' + 'Sony <br>' + 'Haier <br>' ]
88+ document . write ( phone_manufacturers )
0 commit comments