-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
235 lines (204 loc) · 5.75 KB
/
Copy pathjavascript.js
File metadata and controls
235 lines (204 loc) · 5.75 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
"use strict";
//
//
//
//
//
// const blondManitas = ['ayse', 'fatma', 'aylin', 'figen', 'hatice'];
// const brownManitas = ['selen', 'arzu', 'buket', 'ceren'];
// const redManitas = ['cemre', 'marry', 'hazal', 'bar', 'Asli'];
// const allManitas = blondManitas.concat(brownManitas, redManitas);
//
//
// // contacts
// const contacts = ['Leyla:223322', 'Buse:333435', 'Banu:9090909', 'Defne:0303030', 'Dilek:3838843', 'Nalan:334300939'];
//
// const paraContact = document.querySelector('.p-contact');
// const inputContact = document.querySelector('.p-input');
// const btnContact = document.querySelector('.p-button');
//
// if (btnContact !== null) {
//
// btnContact.addEventListener('click', () => {
// const searchName = inputContact.value.toLowerCase();
// inputContact.value = '';
// inputContact.focus();
// paraContact.textContent = '';
//
// for (const contact of contacts) {
// const splitContact = contact.split(':');
// if (splitContact[0].toLowerCase() === searchName) {
// paraContact.textContent = splitContact[0] + `'nin numarasi: ` + splitContact[1] + `.`;
// break;
// }
//
// if (paraContact.textContent === '') {
// paraContact.textContent = `Sana kontak montak yok.`;
// }
// }
//
// });
// }
//
// // integer returner
// const paraNum = document.querySelector('.num-p');
// const inputNum = document.querySelector('.num-input');
// const btnNum = document.querySelector('.num-btn');
//
// if (inputNum !== null) {
// btnNum.addEventListener('click', () => {
// paraNum.textContent = 'Output: ';
// const num = inputNum.value;
// inputNum.value = '';
// inputNum.focus();
//
// for (let i = 1; i <= num; i++) {
// let sqRoot = Math.sqrt(i);
// if (Math.floor(sqRoot) !== sqRoot) {
// continue;
// }
// paraNum.textContent += `${i} `;
// }
//
// });
// }
//
// console.log(inputNum);
//
//
// // while loop with all ladies
//
// let esasManitalar = 'These are the manitas I never can give up: ';
//
// let i = 0;
//
// while (i < allManitas.length) {
// if (i === allManitas.length - 1) {
// esasManitalar += ` and ${allManitas[i]}. `;
// } else {
// esasManitalar += `${allManitas[i]}, `;
// }
//
// i++
// }
//
// console.log(esasManitalar);
//
//
// let sahiciManitalar = `Ladies that I'd always adore: `;
//
// let j = 0;
//
// do {
// if (j === allManitas.length - 1) {
// sahiciManitalar += ` and ${allManitas[j]}. `;
// } else {
// sahiciManitalar += `${allManitas[j]}, `;
// }
//
// j = j + 1;
// } while (j < allManitas.length);
//
// console.log(`\n`);
// console.log(sahiciManitalar);
// countdown to blast
// const btnCount = document.querySelector('.count-button');
// let output = document.querySelector('.output');
// output.innerHTML = 'Ready to launch!';
//
//
// btnCount.addEventListener('click', () => {
// //initializer
// let k = 10;
// output.innerHTML = 'Here we go!';
//
// //loop
// while (k >= 0) {
// const header = document.createElement('h4');
// if (k === 10) {
// header.textContent = `Countdown: ${k}`;
// } else if (k === 0) {
// header.textContent = 'Blast Off!';
// } else {
// header.textContent = `${k}`;
// }
//
// output.appendChild(header);
// k--;
//
// }
// });
// guest list challenge
// lists
const people = ['Chris', 'Anne', 'Collin', 'Terri', 'Phil', 'Lola', 'Sam', 'Kay', 'Bruce'];
const admitted = document.querySelector('.admitted');
const refused = document.querySelector('.refused');
// loop here
for (const guest of people) {
if (guest === 'Phil' || guest === 'Lola') {
admitted.textContent += `${guest}, `;
} else {
refused.textContent += `${guest}, `;
}
}
refused.textContent = refused.textContent.slice(0, refused.textContent.length - 2) + `.`;
admitted.textContent = admitted.textContent.slice(0, admitted.textContent.length - 2) + `.`;
// JAVASCRIPT.INFO loops page study
//while returns boolean?
//
// for (let i = 0; i < 3; i++) {
// alert(`number ${i}!`);
// }
//
//
// let i = 0;
//
// while (i < 3) {
// alert(`number ${i}!`);
// i++;
// }
// noMore: for (let i;; i++) {
// let numHundred = +prompt(`Gimme a number bigger than a hundred.`, '');
// if (!numHundred) {
// break noMore;
// } else if (numHundred < 100) {
// for (let j = 0; j < 2; j++) {
// if (j == 2) {
// break noMore;
// } else {
// alert('I said saclar no dedim. Yenden gir!');
// continue noMore;
// }
// }
// }
// alert('Thank you! But I need more (as always).')
//
// };
// for (let i = 0; i < 2; i++) {
// let numHundred = +prompt('Gimme a number bigger than a hundred.', '');
// if (!numHundred) {
// alert('No kidding?');
// break;
// } else if (numHundred < 100) {
// alert('I said saclar no dedim. Yenden gir!');
//
// }
// }
let numPrime;
primer: for (let numPrime = 2; numPrime < 20; numPrime++) {
for (let i = 2; i < numPrime; i++) {
if (numPrime % i !== 0) {
console.log(`Prime: ${numPrime}`);
} else {
break;
}
}
};
let n = 10;
nextPrime:
for (let i = 2; i <= n; i++) { // for each i...
for (let j = 2; j < i; j++) { // look for a divisor..
if (i % j == 0) continue nextPrime; // not a prime, go next i
}
console.log(i); // a prime
}