2
2
.
.
1
1
.
.
5
5
S
S
t
t
a
a
t
t
e
e
m
m
e
e
n
n
t
t
s
s
-
-
C
C
o
o
n
n
d
d
i
i
t
t
i
i
o
o
n
n
a
a
l
l
I
I
n
n
f
f
o
o
Conditional Statements execute its Body single time if Condition is TRUE
if ... else Statement executes single section for which condition is TRUE
switch...case Statement is used instead if ... else Statement when all conditions evaluate the same variable
? TRUE : FALSE Statement executes first section if Condition is TRUE. Otherwise it executes second section.
if ... else
//TEST VARIABLES.
var number = 10
var text = "Hello"
//IF ELSE STATEMENT.
if (number == 10 ) { print("Number is 10" ) }
else if (text == "Hello") { print("Text equals Hello") }
else if (text == "World") { print("Text equals World") }
else { print("No match found" ) }
switch...case
//TEST VARIABLES.
var number = 10
//SWITCH STATEMENT.
switch (number) {
case 10:
print("number = 10") //Only selected case is executed.
case 20:
print("number = 20")
default:
print("Some other value")
}
? TRUE : FALSE
//TEST VARIABLES.
var left = 20
var right = 10
//CONDITION ? TRUE : FALSE
left > right ? print("TRUE") : print("FALSE")