Skip to content

Commit 28fba36

Browse files
committed
Chapter 4.1 - Grammarly + Upper Letter Titles
1 parent d7dea58 commit 28fba36

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

chapter-04-complex-conditions.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In this **current** chapter, we are going to examine **nested conditional statements** in the **JavaScript** language, by which our program can execute **conditions**, that contain other **nested conditional statements**. We call them **"nested"** because **we put the `if` condition** into **another `if` condition**. We are going to examine the **more complex logical conditions** through proper examples.
44

5-
## Nested conditions
5+
## Nested Conditions
66

77
Pretty often the program logic requires the use of **`if`** or **`if-else`** statements, which are contained one inside another. They are called **nested** **`if`** or **`if-else`** statements. As implied by the title **"nested"**,these are **`if`** or **`if-else`** statements, that are placed inside other **`if`** or **`else`** statements.
88

@@ -38,7 +38,7 @@ Depending on **age** (decimal number) and **gender** (**m** / **f**) print a per
3838

3939
#### Solution
4040

41-
We should notice that the **output** of the program **depends on few things**. First, we have to check what **gender** entered and then to check the **age**. Respectively, we are going to use **a few** **`if-else`** blocks. These blocks will be **nested**, i.e. from the **result** of the first, we are going to **define** which of the **others** to execute.
41+
We should notice that the **output** of the program **depends on a few things**. First, we have to check what **gender** entered and then to check the **age**. Respectively, we are going to use **a few** **`if-else`** blocks. These blocks will be **nested**, i.e. from the **result** of the first, we are going to **define** which of the **others** to execute.
4242

4343
![](/assets/chapter-4-1-images/01.Personal-titles-01.jpg)
4444

@@ -96,7 +96,7 @@ Logical "**AND**" (operator **`&&`**) means a few conditions have to be **fulfil
9696
|-----|-----|-----|
9797
|true<br>true<br>false<br>false|true<br>false<br>true<br>false|true<br>false<br>false<br>false|
9898

99-
### How does The && Operator Work?
99+
### How Does The && Operator Work?
100100

101101
The operator **`&&`** accepts **a couple of Boolean** (conditional) statements, which have a **`true`** or **`false`** value, and returns **one** boolean statement as a **result**. Using it **instead** of a couple of nested **`if`** blocks, makes the code **more readable**, **ordered**, and **easy** to maintain. But how does it **work**, when we put a **few** conditions one after another? As we saw above, the logical **"AND"** returns **`true`**, **only** when it accepts as **arguments statements** with the value **`true`**. Respectively, when we have a **sequence** of arguments, the logical "**AND**" checks either until one of the arguments is **over**, or until it **meets** an argument with value **`false`**.
102102

@@ -114,7 +114,7 @@ let result = a && b && c && d;
114114

115115
The program will run in the **following** way: **It starts** the check from **`a`**, **reads** it, and accepts that it has a **`true`** value, after that, it **checks `b`**. After it has **accepted**, that **`a`** and **`b`** return value **`true`**, **it checks the next** argument. It gets to **`c`** and sees that the variable has a **`false`** value. After the program accepts that argument **`c`** has a **`false`** value, it calculates the expression **to `c`**, **regardless** of what the value of **`d`** is. That is why the evaluation of **`d`**is being **skipped** and the whole expression is calculated as **`false`**.
116116

117-
### Problem: Point in a Rectangle
117+
### Problem: Point in Rectangle
118118

119119
Checks whether **point {x, y}** is placed **inside the rectangle {x1, y1} – {x2, y2}**. The input data is readfrom the console and consists of 6 lines: the decimal numbers **x1**, **y1**, **x2**, **y2**, **x**, and **y** (as it is guaranteed that **x1 < x2** and **y1 < y2**).
120120

@@ -151,7 +151,7 @@ At school, the teacher says: "Ivan or Peter should clean the board". To fulfill
151151
|true<br>true<br>false<br>false|true<br>false<br>true<br>false|true<br>true<br>true<br>false|
152152

153153

154-
### How does The || Operator Work?
154+
### How Does The || Operator Work?
155155

156156
We have already learned what the logical **"OR"** **represents**. But how is it being achieved? Just like the logical **"AND"**, the program **checks** from left to right **the arguments**, that are given. To obtain **`true`** from the expression, just one argument must have a **`true`** value, respectively the checking **continues** until an **argument** with **such** value is met or until the arguments **are over**.
157157

@@ -228,9 +228,9 @@ Like the other operators in programming, the operators **`&&`** and **`||`** hav
228228

229229
## More Complex Logical Conditions
230230

231-
Sometimes the conditions may be very complex, so they can require a long boolean expression or a sequence of conditions. Let's take a look at a few examples.
231+
Sometimes the conditions may be very complex, so they can require a long boolean expression or a sequence of conditions. Let's take a look at a few problems.
232232

233-
### Problem: Point on a Rectangle Border
233+
### Problem: Point on Rectangle Border
234234

235235
Write a program that checks whether a **point {x, y}** is placed **onto any of the sides of a rectangle {x1, y1} - {x2, y2}**. The input data is read from the console and consists of 6 lines: the decimal numbers **x1**, **y1**, **x2**, **y2**, **x**, and **y** (as it is guaranteed that **x1 < x2** and **y1 < y2**). Print "**Border**" (if the point lies on any of the sides) or "**Inside / Outside**" (in the opposite case).
236236

@@ -298,7 +298,7 @@ Write a program that reads from the console **fruit** (banana / apple / …), **
298298
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/931#6](https://judge.softuni.org/Contests/Practice/Index/931#6).
299299

300300

301-
### Problem: Trade Fees
301+
### Problem: Trade Commissions
302302

303303
A company is giving the following **commissions** to its traders according to the **city**, in which they are working and the **volume of sales s**:
304304

@@ -354,7 +354,7 @@ switch (selector) {
354354
}
355355
```
356356

357-
### Problem: Day of The Week
357+
### Problem: Day of Week
358358

359359
Let's write a program that prints the **day of the week** (in English) depending on the **given number** (1 … 7) or "**Error**" if an invalid day is given.
360360

@@ -533,9 +533,9 @@ A sample code (parts of the code are blurred on purpose to stimulate independent
533533
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/931#11](https://judge.softuni.org/Contests/Practice/Index/931#11).
534534

535535

536-
### Problem: * Point in The Figure
536+
### Problem: \* Point in Figure
537537

538-
The figure consists of **6 blocks with size h \* h**, placed as in the figure below. The lower left angle of the building is on position {0, 0}. The upper right angle of the figure is on position {**2\*h**, **4\*h**}. The coordinates given in the figure are for **h = 2**:
538+
The figure consists of **6 blocks with size h \* h**, placed as in the figure below. The lower left angle of the building is on position {0, 0}. The upper right angle of the figure is in position {**2\*h**, **4\*h**}. The coordinates given in the figure are for **h = 2**:
539539

540540
<p><img src="assets/chapter-4-1-images/13.Point-in-the-figure-01.png" /></p>
541541

0 commit comments

Comments
 (0)