Skip to content

Commit 31bb02e

Browse files
feat: truthy and falsy
1 parent 3020898 commit 31bb02e

File tree

4 files changed

+30
-55
lines changed

4 files changed

+30
-55
lines changed
+23-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
// Falsy value
1+
// Truthy VS Falsy
2+
3+
// Falsy value: Any value which is treated as a false. Known as a falsy value.
24
// false
35
// 0
46
// -0
57
// BigInt 0n
6-
// ""
8+
// Empty string: ""
79
// null
810
// undefined
911
// NaN
1012

11-
// Truthy value
12-
// - Any value other than falsy.
13+
if (0) {
14+
console.log("code executed");
15+
}
16+
17+
// Truthy value: Any value other than falsy.
1318
// "0"
1419
// "false"
15-
// " "
20+
// String with white space: " "
1621
// []
1722
// {}
1823
// function(){}
1924

20-
// For CP and Interview
21-
// false == 0 -> true
22-
// false == "" -> true
23-
// 0 == "" -> true
24-
2525
const emptyArray = [];
2626
if (emptyArray.length === 0) {
2727
console.log("Array is empty");
@@ -31,3 +31,16 @@ const emptyObject = {};
3131
if (Object.keys(emptyObject).length === 0) {
3232
console.log("Objet is empty");
3333
}
34+
35+
// For Interview
36+
// false == 0 -> true
37+
// false == -0 -> true
38+
// false == 0n -> true
39+
// false == "0" -> true
40+
// false == "" -> true
41+
42+
// false == null -> false
43+
// false == undefine -> false
44+
// false == NaN -> false
45+
const result = false == NaN;
46+
console.log(result);

code_test_space.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
// TODO: This example is connected to the closer concept which is the video number - 49.
1+
// TODO: This example is connected to the closer concept which is the video number - 49.
22
// function outerRegularFunction() {
33
// const variable = "value";
44
// function innerRegularFunction() {
55
// console.log(this.variable);
66
// }
77
// console.log(innerRegularFunction());
88
// }
9-
// console.log(outerRegularFunction());
9+
// console.log(outerRegularFunction());
10+
11+
const num = 1
12+
if (num) {
13+
console.log("hey");
14+
}

notes/theme_test.js

-43
This file was deleted.

project/1_color_changer/index.html

Whitespace-only changes.

0 commit comments

Comments
 (0)