-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
354 lines (285 loc) ยท 7.67 KB
/
index.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
//hello world
/*
let js = 'amazing';
console.log(40 + 8 + 23 -10);
console.log('oren');
console.log(8);
let firstName = 'oren';
console.log(firstName);
console.log(firstName);
console.log(firstName);
// variable name conventions
let OrenAndNoa = 'on';
let $function = 8;
let person = 'oren'
let PI = 3.1415;
let MyFirstJob = 'coder';
let MyCurrentJob = 'Teacher';
let job1 = 'programmer';
let job2 = 'teacher';
console.log(MyFirstJob);
*/
/*
let javascriptIsFun = true;
console.log(javascriptIsFun);
// console.log(typeof true);
console.log(typeof javascriptIsFun);
// console.log(typeof 8);
// console.log(typeof 'oren');
javascriptIsFun = 'YES!';
console.log(typeof javascriptIsFun);
let year;
console.log(year);
console.log(typeof year);
year = 2012;
console.log(typeof year);
console.log(typeof null);
*/
//let const and var
/*
let age = 8;
age = 9;
// const BirthYear = 2012;
// BirthYear = 2021
var job = 'programmer';
job = 'teacher';
let LastName = 'vilaret';
console.log(LastName);
*/
//basic operators
/*
//Math operators
const Now = 2021;
const AgeOren = Now - 2012;
const AgeNoa = Now - 2015;
console.log('oren:',AgeOren, 'noa:', AgeNoa);
console.log(AgeOren * 2, AgeOren / 2);
const FirstName = 'oren';
const LastName = 'villaret';
console.log(FirstName + ' ' + LastName);
//Assignment operators
let x = 10 + 5;
x += 10;
x *= 4;
x++;
x--;
x--;
console.log(x);
//Comparison operators
console.log(AgeOren > AgeNoa);
console.log(AgeNoa >= 5);
const IsFulAge = AgeNoa >= 5;
console.log(Now - 2012 > Now - 2015);
*/
//Operator Precedence
/*
const Now = 2021;
const AgeOren = Now - 2012;
const AgeNoa = Now - 2015;
console.log(Now - 2012 > Now - 2015);
let x, y;
x = y = 25 - 10 -5;
console.log(y, x);
const Age = (AgeOren + AgeNoa) / 2;
console.log(Age, AgeNoa, AgeOren);
*/
//Coding Challenge #1
/*
const MassOren = 25;
const HeightOren = 1.35
const MassNoa = 18;
const HeightNoa = 1.10;
const BMIOren = MassOren / HeightOren ** 2;
const BMINoa = MassNoa / (HeightNoa * HeightNoa);
const OrenHigherBMI = BMIOren > BMINoa;
console.log(BMINoa, BMIOren, OrenHigherBMI);
*/
//Strings and Template Literals
/*
const FirstName = 'oren';
const job = 'student';
const BirthYear = 2012;
const Year = 2021;
const Oren = "I'm " + FirstName + ', a ' + (Year - BirthYear) + ' years old ' + job + '!';
console.log(Oren);
const NewOren = `i'm ${FirstName}, a ${Year - BirthYear} year old ${job}!`;
console.log(NewOren);
console.log(`just a regular string... `);
console.log('string with \n\ multiple \n\ lines');
*/
//Taking Decisions: if / else Statements
/*
const age = 8;
if(age >= 7){
console.log('oren');
}else{
console.log('noa');
}
let century
const BirthYear = 2012;
if (BirthYear <= 2000){
century = 20;
}else{
century = 21;
}
console.log(century);
*/
//Coding Challenge #2
/*
const MassOren = 25;
const HeightOren = 1.35
const MassNoa = 18;
const HeightNoa = 1.10;
const BMIOren = MassOren / HeightOren ** 2;
const BMINoa = MassNoa / (HeightNoa * HeightNoa);
console.log(BMIOren, BMINoa);
if(BMINoa > BMIOren){
console.log(`Noa's BMI (${BMINoa}) is higher than oren's (${BMIOren})`);
}else{
console.log(`oren's BMI (${BMIOren}) is higher than Noa's (${BMINoa})`);
}
*/
//Type Conversion and coercion
/*
const InputYear = '2012';
console.log(Number(InputYear), InputYear);
console.log(Number(InputYear) + 8);
console.log(Number('jonas'));
console.log(typeof NaN);
console.log(String(8), 8);
console.log('i am ' + 8 + ' years old');
console.log(('23' + '10' + 3));
console.log('23' / '2');
console.log('23' > '18');
let n = '1' + 1;
n = n -1;
console.log(n);
*/
//Truthy and Falsy Values
/*
console.log(Boolean(0));
console.log(Boolean(undefined));
console.log(Boolean('oren'));
console.log(Boolean({}));
console.log(Boolean(''));
const money = 0;
if (money) {
console.log("don't spend it all");
}else{
console.log('you should get a job!');
}
let height;
if (height){
console.log('yay height is defined')
}else {
console.log('height is undefined')
}
*/
// Equality Operators: == vs. ===
/*
const Age = 8;
if (Age === 8){
console.log(Age);
}
if (8 == Age){
console.log(0)
}
const favourite = Number(prompt("what's your favourite number"));
console.log(typeof favourite);
*/
//Logical Operators
/*
const HesDrivingLicense = true; // A
const HesGoodVision = true; // B
console.log(HesDrivingLicense && HesGoodVision);
console.log(HesDrivingLicense || HesGoodVision);
console.log(!HesDrivingLicense);
// if (HesDrivingLicense && HesGoodVision){
// console.log('ifat is able to drive!');
// }else{
// console.log('someone else should drive...')
// }
const IsTired = false; // C
console.log(HesDrivingLicense && HesGoodVision && IsTired && !IsTired);
if (HesDrivingLicense && HesGoodVision){
console.log('ifat is able to drive!');
}else{
console.log('someone else should drive...')
}
*/
//Coding Challenge #3
/*
// const ScoreDolphins = (96 + 108 + 89) / 3;
// const ScoreKoalas = (88 + 91 + 110) / 3;
// console.log(ScoreDolphins, ScoreKoalas);
//
// if (ScoreDolphins > ScoreKoalas){
// console.log('dolphins win the trophy ๐');
// }else if (ScoreKoalas > ScoreDolphins){
// console.log('koalas win the trophy ๐');
// }else if (ScoreDolphins === ScoreKoalas){
// console.log('both win the trophy ๐');
// }
//bonus 1
const ScoreDolphins = (97 + 112 + 80) / 3;
const ScoreKoalas = (109 + 95 + 50) / 3;
console.log(ScoreDolphins, ScoreKoalas);
if (ScoreDolphins > ScoreKoalas && ScoreDolphins >= 100){
console.log('dolphins win the trophy ๐');
}else if (ScoreKoalas > ScoreDolphins && ScoreDolphins >= 100){
console.log('koalas win the trophy ๐');
}else if (ScoreDolphins === ScoreKoalas && ScoreDolphins >= 100 && ScoreKoalas >= 100){
console.log('both win the trophy ๐');
}else{
console.log('no one wins the trophy๐ญ')
}
*/
//The switch Statement
/*
const Day = 'wednesday';
switch (Day){
case "monday": //if day === 'monday'
console.log('Plan course structure');
console.log('go to coding meetup');
break;
case 'tuesday': // if day === tuesday
console.log('prepare theory videos');
break;
default:
console.log('not a valid day!')
}
*/
//Statements and Expressions
/*
3 + 4
1991
true && false && !false
if (23 > 10){
const str = '23 is bigger';
}
const me = 'oren';
console.log(`i am ${2021 - 2012} years old ${me}`);
*/
//The Conditional (Ternary) Operator
/*
const age = 9;
age >= 8 ? console.log('yes') :
console.log('no');
const yes_or_No = age >= 8 ? 'yes' : 'no';
console.log(yes_or_No);
let yes_or_no_2;
if(age >= 8){
yes_or_no_2 = 'yes'
}else{
yes_or_no_2 = 'no'
}
console.log(yes_or_no_2);
*/
//Coding Challenge #4
/*
const bill = 275
const tip = bill <= 300 && bill >= 50 ? bill * 0.15 :
bill* 0.2;
console.log(`the bill was ${bill} the tip was ${tip}, and the total value ${bill + tip}`)
*/
//JavaScript Releases: ES5, ES6+ and ESNext