-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIf_Else.js
More file actions
53 lines (40 loc) · 1.15 KB
/
If_Else.js
File metadata and controls
53 lines (40 loc) · 1.15 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
/* Control structures determine how the program flows. JavaScript has 2 important types of control structures;
conditionals and loops.
JavaScript has different kind of structures that can help in multiple situations:
Conditionals
if / else
switch
Loops
for
for..of
for..in
while
do..while
Array.forEach
*/
//An if statement is used to make a program take a route, or another, depending upon the result of an express evaluation.
//the conditional checks the expression i pass to it for a true or false value. If i pass a number, that always evaluates
//as true unless the number is 0. If i pass a string, it always evaluates to true unless its an empty string.
//these are rules for casting types to boolean
if (true) {
//do something
}
//If there is a single statement to execute after the conditionals, the block can be omitted, just write statement
if (true) (a + b)
//Else is the statement that is executed if the condition is false.
if (true) {
//do something
}
else {
//do something else
}
//Else if
if (c === true) {
//do something
}
else if(r===true){
//do something else
}
else {
//default
}