1/*Regardless of the complexity of a conditional, no more than one of
2the code blocks will be executed.*/
3
4let x = 10;
5let y = 20;
6
7if (x > y) {
8 console.log("x is greater than y");
9} else if (x < y) {
10 console.log("x is less than y");
11} else if (x % 5 === 0) {
12 console.log("x is divisible by 5");
13} else if (x % 2 === 0) {
14 console.log("x is even");
15}
16//x is less than y
17
18/*Even though both of the conditions x % 5 === 0 and x % 2 === 0
19evaluate to true, neither of the associated code blocks is executed.
20When a condition is satisfied, the rest of the conditional is
21skipped.*/
1/*If-else statements allow us to construct two alternative paths.
2A single condition determines which path will be followed. We can
3build more complex conditionals using an else if clause. These allow
4us to add additional conditions and code blocks, which facilitate more
5complex branching.*/
6
7let x = 10;
8let y = 20;
9
10if (x > y) {
11 console.log("x is greater than y");
12} else if (x < y) {
13 console.log("x is less than y");
14} else {
15 console.log("x and y are equal");
16}
17//x is less than y