-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsQuestions.js
More file actions
271 lines (217 loc) · 6.26 KB
/
Copy pathJsQuestions.js
File metadata and controls
271 lines (217 loc) · 6.26 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
// 1. Print Even number
// for(let i=1;i<=20;i++){
// if(i%2===0){
// console.log("EVEN :- " + i)
// }
// }
// for(let i=2;i<=20;i+=2){ // simple way
// console.log("EVEN :- " + i)
// }
// 2. Print Reverse Number
// for(let i=10;i>0;i--){
// console.log(i)
// }
// 3. Print word 5 times
// for(let i=1;i<=5;i++){
// console.log("yes")
// }
// 4. Print EVEN ODD if me EVEN else me ODD
// for(let i=1;i<=10;i++){
// if(i%2===0){
// console.log(`${i} - Even`)
// }
// else{
// console.log(`${i} - Odd`)
// }
// }
// 5. Ask user a numeber and say if is it +ve or -ve using prompt
// let num= +prompt("number do")
// if(num>=0){
// console.log(`${num} - Positive number`)
// }
// else{
// console.log(`${num} - Negative number`)
// }
// 6. check whether user is eligible for vote or not
// let age=+prompt("Age Batao")
// if(age>=18){
// console.log(`You are ${age}, you can vote`)
// }
// else{
// console.log(`You are ${age}, you can't vote`)
// }
// let age = prompt("age batao");
// if (age === null) {
// console.error("abe cancel dabya ");
// } else {
// if (age.trim() === "") {
// console.error(`bhai sahi se likh le `);
// } else {
// age = Number(age.trim());
// if (isNaN(age)) {
// console.warn("bhai please number dede....");
// } else {
// if (age < 0) console.error("Negative value dala");
// else if (age >= 18 && age<=125) console.log(` your age is ${age} you can vote`);
// else console.warn(`your age is ${age} you can't vote`);
// }
// }
// }
// // 7 . Print 5 ka table
// for(let i=1;i<=10;i++){
// console.log(`38 X ${i} = `+ i*38)
// }
// 9 . Count how many number between 1 and 15 are greater than 8 Loop and count conditionally
// let count = 0;
// for(let i =1; i<=15;i++){
// if(i>8){
// count++;
// console.log(i)
// }
// }
// console.log(`total count is ${count}`)
// 10. Ask user for password and print access status
// let password = "Admin@123";
// let pass = prompt("password de de bhai");
// if (pass === null) {
// console.log("you cancelled it");
// } else {
// if (pass === password) {
// console.log("matched");
// } else {
// console.log("not matched");
// }
// }
// LEVEl 2 :- 11. Allow only 3 attemt to enter correct password if user gets it right early, stop. if not Account Locked
// let pass = prompt("naam batao ");
// while (pass !== "stop") {
// pass = prompt("naam batao ");
// console.log(pass);
// }
// let attempt = 0;
// let khulgaya = false;
// let pass = "Aakash";
// let password = prompt("Password Batao");
// attempt++;
// if (password === pass) khulgaya = true;
// while (password !== pass) {
// if (attempt === 3) {
// console.error("Account Locked");
// break;
// }
// password = prompt("Password Batao");
// if (password === pass) khulgaya = true;
// attempt++;
// }
// if (khulgaya === true) console.log("account opend");
//apna password difine karo
// ek baar password puchho
// while banao jo tab tak chale jab tak password match na kar jaye
// let sahipassword = "Aakash";
// let attempt = 0;
// let userpass = prompt("Password Please");
// attempt++;
// while (sahipassword !== userpass) {
// if (attempt === 3) {
// console.error("Locked")
// break;
// }
// attempt++;
// pass = prompt("Password Please");
// }
// let attempt = 0;
// let sahipassword = "Aakash"
// let userpass = prompt ("password please")
// attempt++;
// while(attempt<3 && sahipassword !== userpass){
// userpass = prompt ("password please");
// attempt++;
// }
// if(attempt ===3 && sahipassword !== userpass){
// console.error("Lock Ho gya")
// }else{
// console.log("Done")
// }
// 12. ask user for words until they type "stop", count how many times they type "yes"
// loop until "stop" is typed. count yes
// let word = prompt("word bolo");
// let counter = 0;
// while (word !== "stop") {
// if (word === "yes") counter++;
// word = prompt("word bolo");
// }
// console.log(`total times yes count : ${counter}`);
// 13 Print numbers divisible by 7 from 1 to 50
// use modulo % and loop
// for(let i = 1; i<=50;i++){
// if(i%7===0){
// console.log(i)
// }
// }
// 14 sum of all odd numbers from 1 to 30 add only odd numbers print final sum
// let sum = 0;
// for(let i=1;i<=30;i++){
// if(i%2 !==0){
// sum=sum+i
// }
// }
// console.log(sum)
// 15 keep asking number untill user enters an even number use while loop Stop only if input is even
// let num = prompt("Enter the number");
// num = Number(num);
// while (num % 2 !== 0) {
// num = prompt("Enter the number");
// num = Number(num);
// }
// console.log(num)
// 16. Print numbers between two user inputs, Input start and end using prompt() print all between
// let start = +prompt("start number")
// let end = +prompt("End Number")
// if(start>end){
// console.error("phela input bada de de....")
// }
// for(i=start;i<=end;i++){
// console.log(i)
// }
// 17. print only first 3 odd numbers from 1 to 20 use Loop. stop with break after 3 odd prints
// let counter =0;
// for(let i = 1; i<=20;i++){
// if(counter ===3)break;
// if(i%2!==0){
// console.log(i)
// counter++
// }
// }
// 18. Ask user 5 numbers. Count how many are positive use loop + condtion + counter
// let counter =0;
// for(let i=1;i<=5;i++){
// let numbers = +prompt("enter the number")
// if (numbers>=0){
// // console.log(numbers)
// counter++
// }
// }
// console.log(`ther are ${counter} positive number you have entered`)
// 19. ATM Simulator – Allow 3 withdrawals Start with ₹1000 balance. Ask withdrawal amount 3 times. if enough balance → deduct Else → print “Insufficient balance”
// let balance = 1000;
// let totalwithdraw=0;
// let flag = false;
// let counter = 0;
// while (balance > 0 && counter !== 3) {
// let withdraw = +prompt(
// "kitna paise withdraw karna hai yaad rhe 3 he baar kar sakte ho",
// );
// counter++;
// if (withdraw <= balance) {
// balance -= withdraw;
// totalwithdraw +=withdraw
// } else {
// flag = true;
// break;
// }
// }
// if (flag === true) {
// console.log("Insufficient balance");
// }
// console.log(`you have withdrawal :- ${totalwithdraw}`)
// console.log(`avilable balance is :- ${balance} `);