2022-07-24 23:03:35 +08:00
|
|
|
//! This script runs if statements.
|
2022-01-20 12:06:36 +08:00
|
|
|
|
2020-03-16 14:50:12 +08:00
|
|
|
let a = 42;
|
|
|
|
let b = 123;
|
|
|
|
let x = 999;
|
|
|
|
|
|
|
|
if a > b {
|
2020-05-02 16:23:36 +08:00
|
|
|
print("Oops! a > b");
|
2020-03-16 14:50:12 +08:00
|
|
|
} else if a < b {
|
2020-05-02 16:23:36 +08:00
|
|
|
print("a < b, x should be 0");
|
2020-03-16 14:50:12 +08:00
|
|
|
|
2022-01-20 12:06:36 +08:00
|
|
|
let x = 0; // <- this 'x' shadows the global 'x'
|
2020-03-16 14:50:12 +08:00
|
|
|
print(x); // should print 0
|
|
|
|
} else {
|
2020-05-02 16:23:36 +08:00
|
|
|
print("Oops! a == b");
|
2021-04-09 22:48:47 +08:00
|
|
|
}
|