-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
142 lines (130 loc) · 3.65 KB
/
Copy pathscript.js
File metadata and controls
142 lines (130 loc) · 3.65 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
//1. type conversion
// string
const inputNumber = "7500";
console.log(inputNumber + 10);
console.log(typeof inputNumber); // string
console.log(Number(inputNumber), inputNumber); // convert to number use number function
console.log(typeof Number(inputNumber));
// Number
const birthYear = 1992; // number
console.log(String(birthYear)); //convert to string use string function
console.log(typeof String(birthYear));
const firstName = "AnikAhmed";
console.log(Number(firstName)); // this is NaN value
// 2. type coercion
let numberGet = 5;
console.log("i have " + numberGet + " story book !");
console.log("20" - 5); // it will automatic substrack and give 15 as number
console.log("20" + 5); // it will not add string it will concatinate as result 205
console.log("20" * 5);
console.log("20" - "15" + 5); // it will substrack and give number as result and add 5 as number
// 3. javaScript Truthy and Falsy Value
// there are 5 falsy value
// 0
// NaN
// null
// ""
// undefined
console.log(Boolean(0)); //Falsy
console.log(Boolean(NaN));
console.log(Boolean(null));
console.log(Boolean(""));
console.log(Boolean(undefined));
console.log(Boolean(1)); //Truthy
//example
let job = 0; // false value
if (job) {
console.log("i have good job !");
} else {
console.log("looking for a good job !");
}
let gotJob = 1; // truthy value
if (gotJob) {
console.log("i have good job !");
} else {
console.log("looking for a good job !");
}
let salery;
if (salery) {
console.log("my salery is set !");
} else {
console.log("my salery is not set !");
}
// 4. conditional statement
let earning = 25000;
if (earning > 35000) {
console.log("his earing is excellent !");
} else if (earning > 20000) {
console.log("his earning is good !");
} else if (earning > 10000) {
console.log("his earning is average !");
} else {
console.log("his earnign is not good enough !");
}
// example
let today = "Friday";
if (today === "Satarday") {
console.log("Today 9 pm we have main live class");
} else if (today === "Sunday") {
console.log("Today 9 pm we have support class");
} else if (today === "Monday") {
console.log("Today 9 pm we have main live class");
} else if (today === "Tuesday") {
console.log("Today 9 pm we have support class");
} else if (today === "Wednesday") {
console.log("Today 9 pm we have main live class");
} else if (today === "Thusday") {
console.log("Today 9 pm we have support class");
} else if (today === "Friday") {
console.log("Today is holiday");
} else {
console.log(
"ERROR ! please select days eg: Satarday, Sunday etc or check spelling is correct"
);
}
// 5. nested condition statement
let x = 10;
if (x >= 10) {
if (x == 10) {
console.log("X is equal then 10 !");
} else {
console.log("X is greater then 10 !");
}
} else if (x >= 5) {
if (x == 5) {
console.log(" X is equal then 5 !");
} else {
console.log(" X is greater then 5 !");
}
} else {
console.log(" X is lower then 5 !");
}
// 6. switch statement
let day = "";
switch (day) {
case "Satarday":
console.log("Today 9 pm we have main live class !");
break;
case "Sunday":
console.log("Today 9 pm we have support class !");
break;
case "Monday":
console.log("Today 9 pm we have main live class !");
break;
case "Tuesday":
console.log("Today 9 pm we have support class !");
break;
case "Wednesday":
console.log("Today 9 pm we have main live class !");
break;
case "Thusday":
console.log("Today 9 pm we have support class !");
break;
case "Friday":
console.log("Today is Holiday 2 !");
break;
default:
console.log(
"ERROR ! please select days eg: Satarday, Sunday etc or check spelling is correct"
);
}