1/*Our first attempt at a solution might look like this:
2(NOT USING NESTED CONDITIONALS)*/
3let num = 7;
4
5if (num % 2 === 0) {
6 console.log("EVEN");
7}
8
9if (num > 0) {
10 console.log("POSITIVE");
11}
12//POSITIVE
13
14/*We find that the output is POSITIVE, even though 7 is odd and so
15nothing should be printed. This code doesn't work as desired because
16we only want to test for positivity when we already know that the
17number is even. We can enable this behavior by putting the second
18conditional inside the first.*/
19
20//USING NESTED CONDITIONALS:
21let num = 7;
22
23if (num % 2 === 0) {
24 console.log("EVEN");
25
26 if (num > 0) {
27 console.log("POSITIVE");
28 }
29}
30
31/*Notice that when we put one conditional inside another, the body of
32the nested conditional is indented by two tabs rather than one. This
33convention provides an easy, visual way to determine which code is
34part of which conditional.*/