forked from Swap76/Learn-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif.js
More file actions
32 lines (25 loc) · 822 Bytes
/
Copy pathif.js
File metadata and controls
32 lines (25 loc) · 822 Bytes
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
// IF keyword condition
// this is used to create condition block of code
// the if needs a condition that the result is true and execute the
// code inside of the if block
const condition = 2 % 2 === 0
if (condition) {
// run this code
console.log('YEAH THIS RUN BECAUSE THE CONDITION IS A HARDCODE true')
}
// have a default value if the condition is false
// this runs in the else code block
if (condition) {
// this block of code is never executed
} else {
// run this code
console.log('YEAH THIS RUN BECAUSE THE CONDITION IS A HARDCODE false')
}
// and you can make more conditions with an ELSE IF keyword
if (!condition) {
// this block of code is never executed
} else if (condition) {
// this code is executed because 1 is true like binary
} else {
// this block of code is never executed
}