-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
235 lines (152 loc) · 5.95 KB
/
app.js
File metadata and controls
235 lines (152 loc) · 5.95 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
/// CHAPTER 21-25 STRING METHODS ///
// Q NO. 1
// var firstName = prompt("Enter Your First Name");
// var lastName = prompt("Enter Your Last Name");
// var fullName = firstName + lastName;
// document.write("Assalam Alaikum " + fullName);
// Q NO. 2
// var favMobile = prompt("Enter Your Favourite Mobile Phone");
// document.write("Your Favourite Phone Is: " + favMobile);
// document.write("<br><br>Length Of String: " + favMobile.length);
// Q NO. 3
// var nationality = "Pakistani";
// document.write("String: " + nationality);
// var index = nationality.indexOf("n");
// document.write("<br>Index of 'n':" + index);
// Q NO. 4
// var hi = "Hello World";
// var index = hi.lastIndexOf("l");
// document.write("String: " + hi);
// document.write("<br>Last index of 'l': " + hi.lastIndexOf("l"));
// Q NO. 5
// var nationality = "Pakistani";
// document.write("String: " + nationality);
// document.write("<br>Character at index 3: " + nationality.charAt(3));
// Q NO. 6
// var firstName = prompt("Enter Your First Name");
// var lastName = prompt("Enter Your Last Name");
// var fullName = firstName.concat(lastName);
// document.write("Assalam Alaikum " + fullName);
// Q NO. 7
// var city = "Hyderabad";
// document.write("City: " + city);
// var replacemet = city.replace("Hyder", "Islam");
// document.write("<br>After Replacemet: " + replacemet);
// Q NO. 8
// var para = "Ali and Sami are best friends. They play cricket and football together."
// var uptPara = para.replace(/and/g, "&");
// document.write("<strong>String: </strong> " + para);
// document.write("<br><strong>After Replacement: </strong> " + uptPara);
// Q NO. 9
// var string = "472";
// var number = parseInt(string);
// document.write("value: " + string);
// document.write("<br>Type: " +typeof string);
// document.write("<br>value: " + number);
// document.write("<br>Type: " +typeof number);
// Q NO. 10
// var userInput = prompt("Enter Something");
// document.write("User Input: " + userInput);
// document.write("<br>UPPER CASE: " + userInput.toUpperCase());
// Q NO. 11
/*
var userInput = prompt("Enter an Alphabet");
document.write("User Input: " + userInput);
var firstChar = userInput.slice(0,1);
var capWord = firstChar.toUpperCase();
var uptPara = userInput.slice(1);
document.write("<br>Title case: " + capWord.concat(uptPara));
*/
// Q NO. 12
// var num = 35.36 ;
// var str = num.toString();
// var uptPara = str.replace(".", "")
// document.write(typeof num + " " + num);
// document.write("<br>" + typeof uptPara + " " + uptPara);
// Q NO. 13
// Q NO. 14
/*
var items = ["cake", "apple pie", "cookie", "chips", "patties"];
var userItem = prompt("Welcome To Marvel Bakery.What do you want to order Sir/Maam");
var flag = false
for (var i = 0; i < items.length; i++) {
if (userItem.toLowerCase() === items[i]) {
document.write(userItem + " is <strong>Available</strong> at index " + i + " is " + items[i] + "<br>");
flag = true
}
}
if (flag === false) {
document.write("We are Sorry " + userItem + " is <strong>Not Available</strong> in our bakkery" + "<br>");
}
*/
// Q NO. 15
// var userPassword = prompt("Enter Your Password");
// for(var i = 65; i < 90; i++){
// var password = String.fromCharCode(i);
// if(userPassword == password){
// console.log("OK");
// }
// }
// Q NO. 16
// var university = "University of Karachi";
// var uptUniversity = university.split("");
// document.write(uptUniversity);
// Q NO. 17
// var userInput = "Pakistan";
// document.write("User Input: " + userInput);
// document.write("<br>Last character: " + userInput.lastIndexOf("n"));
// Q NO. 18
// var para = "The quick brown fox jumps over The lazy dog";
// document.write("Text: " + para);
// var uptPara = para.match(/The/g);
// document.write("<br>" + uptPara);
/// CHAPTER 26-30 MATH METHODS ///
// Q NO. 1
// var num = +prompt("Enter a Number:");
// document.write("Number: " + num);
// document.write("<br>Round off value: " + Math.round(num));
// document.write("<br>Floor value: " + Math.floor(num));
// document.write("<br>Ceil value: " + Math.ceil(num));
// Q NO. 2
// var num = -prompt("Enter a Number:");
// document.write("Number: " + num);
// document.write("<br>Round off value: " + Math.round(num));
// document.write("<br>Floor value: " + Math.floor(num));
// document.write("<br>Ceil value: " + Math.ceil(num));
// Q NO. 3
// var num = +prompt("Enter a Negative Number:");
// document.write("Value: " + num);
// document.write("<br>Absolute Value: " +Math.abs(num));
// Q NO. 4
// var diceValue = Math.round((Math.random() *6) + 1);
// document.write("Random dice value: " + diceValue);
// document.write("<br>Random dice value: " + diceValue);
// Q NO. 5
// var coin = Math.round((Math.random() *1) + 1);
// if (coin === 2) {
// document.write(coin + "<br>" + "Random Coin Value: <strong>Heads</strong>");
// }
// else{
// document.write(coin + "<br>" + "Random Coin Value: <strong>Tails</strong>");
// }
// Q NO. 6
// var number = Math.round((Math.random() *100) + 1);
// document.write("Random number between 1 and 100: " + number);
// Q NO. 7
// var userWeight= Number(prompt("Enter Your Weight"));
// if (userWeight==Math.round(userWeight) || userWeight==Math.floor(userWeight)) {
// document.write("<br><br>The weight of the user is"+userWeight +"");
// document.write("<br><br>The weight of the user is"+userWeight +"Kilograms");
// document.write("<br><br>The weight of the user is"+userWeight +"KG");
// } else {
// document.write("Wrong");
// }
// Q NO. 8
// var secretNum = Math.round((Math.random() *10) + 1);
// var userNum = prompt("Enter a number between 1 to 10:");
// if (userNum === secretNum) {
// document.write("Congrats!");
// }
// else{
// alert("Try Again!");
// }