-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
102 lines (74 loc) · 2.06 KB
/
script.js
File metadata and controls
102 lines (74 loc) · 2.06 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
/*
const firstName = 'Brian'
const age = 23
const job = 'Software Developer'
const birthYear = 1997
const year = 2040
// using template strings
const jonasNew = `I am ${firstName}, a ${year - birthYear}, old ${job}`
console.log(jonasNew)
const age = 13
//const isOldEnough = age >= 18
if(age >= 19){
console.log('Sarah can start driving')
}else {
const yearsLeft = 18 - age
console.log(`Sarah is too young. wait another ${yearsLeft} years`)
}
const yearBirth = 2012
let century
if(yearBirth <=2000){
century = 20
}else {
century = 21
}
console.log (century)
//falsy value include: 0, '', undefined, null, NaN
console.log(Boolean(0))
console.log(Boolean(undefined))
console.log(Boolean('Brian'))
console.log(Boolean({}))
const money = 0
if (money){
console.log('do not spend it all')
}else{
console.log('save it and get a job')
}
let height
if (height){
console.log('YAY! Height is defined')
}
else{
console.log('Height is UNDEFINED')
}
const age = 10
if (age === 18) console.log('You just became an adult')
const favourite = Number(prompt("what is your favourite number"))
console.log(favourite)
console.log(typeof favourite)
if (favourite === 23){ //'23' == 23
console.log('This 23 is an amazing number')
}else if (favourite === 7) {
console.log('7 is also a cool number')
}else {
console.log('number is not 7 or 23')
}
if(favourite !== 23) (console.log('Why not the 23'))
*/
// const koalaScore = (98 + 52 + 60) / 3
// const dolphinScore = (100 + 78 + 65) / 3
// console.log( koalaScore, dolphinScore)
// if (koalaScore > dolphinScore){
// console.log( 'Koala wins the trophy')
// }else if(dolphinScore > koalaScore){
// console.log('Dolphins wins the trophy')
// }else if( dolphinScore === koalaScore){
// console.log('Both teams win the trophy')
// }
//ternary operator. if and else
const age = 23
// age >= 18 ? console.log('I like to drink wine'):
const drink = age >= 18 ? 'wine' : 'water'
console.log(drink)
// console.log('I like to drink water')
console.log (`I like to drink ${age >= 18 ? 'wine' : 'water'}`)