-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
106 lines (84 loc) · 2.64 KB
/
index.js
File metadata and controls
106 lines (84 loc) · 2.64 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
// Using if/else statements, create a JavaScript code in a script tag that follows the following rules:
// If the value is truthy, print true;
// If the value is falsy, print the corresponding result:
// "The boolean value false is falsy";
// "The null value is falsy";
// "undefined is falsy";
// "The number 0 is falsy (the only falsy number)";
// "The empty string is falsy (the only falsy string)";
//
// if (String) {
// console.log(true)
// } else{
// console.log(false)
// }
// let the string be true
// let the statement be "I am string"
// create a statemnt that will print true if "I am a sting" is a truthy statement.
let userString = 'true';
let statementName;
if (userString){
statementName = userString;
} else {
statementName = 'I am a string';
}
console.log(statementName);
// let the boolean value be false
// let the statement determine if the value "false" is considered falsy (set it equal to eachother)
// if this is true the statement will print out "the boolean value false is falsy"
let boolean = 'The boolean value false is falsy';
let booleanName;
if (boolean){
booleanName = boolean;
} else {
booleanName = 'false';
}
console.log(booleanName);
// create an if/else statement
//if "null" is considered false statement
// the statement will output "the null value is falsy"
// set the nullValue = to null to determine if null is a falsy value.
let nullValue = 'The null value is falsy';
let nullName;
if (nullValue){
nullName = nullValue;
} else {
nullName = 'null';
}
console.log(nullName);
// create an if/else statement
//if "undefined" is considered falsy value
// the statement will output "undefined is falsy"
// set the undeValue = to undefined to determine if undefined is a falsy value.
let undeValue = 'undefined is falsy';
let undeName;
if (undeValue){
undeName = undeValue;
} else {
undeName = 'undefined';
}
console.log(undeName);
// create an if/else statement
//if "0" is considered falsy value
// the statement will output "The number 0 is falsy (the only falsy number)"
// set the numValue = to 0 to determine if 0 is a falsy value.
let numValue = 'The number 0 is falsy (the only falsy number)';
let numName;
if (numValue){
numName = numValue;
} else {
numName = 0;
}
console.log(numName);
// create an if/else statement
//if "" is considered a falsy value
// the statement will output "The empty string is falsy (the only falsy string)"
// set the empValue = to "" to determine if "" is a falsy value.
let empValue = 'The empty string is falsy (the only falsy string)';
let empName;
if (empValue){
empName = empValue;
} else {
empName = "";
}
console.log(empName);