Fixed Critical Typographical Issues

In Exercises: Level 2, a task asks for a code that returns grades according to students' scores. Two ranges overlap (80-100 A, 10-89 B) which may cause errors when returning a result.

Changes applied:
89 -> 79
theirs -> their
Added appropriate punctuations.
Deleted extra blank space.
pull/623/head
Seliun 3 years ago
parent 33cf6c074d
commit 32f190f646

@ -11,6 +11,7 @@
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br> <a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
<small> January, 2020</small> <small> January, 2020</small>
</sub> </sub>
</div> </div>
[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) [<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md)
@ -61,9 +62,9 @@ if (condition) {
**Example:** **Example:**
```js ```js
let num = 3 let num = 3;
if (num > 0) { if (num > 0) {
console.log(`${num} is a positive number`) console.log(`${num} is a positive number`);
} }
// 3 is a positive number // 3 is a positive number
``` ```
@ -71,9 +72,9 @@ if (num > 0) {
As you can see in the condition example above, 3 is greater than 0, so it is a positive number. The condition was true and the block of code was executed. However, if the condition is false, we won't see any results. As you can see in the condition example above, 3 is greater than 0, so it is a positive number. The condition was true and the block of code was executed. However, if the condition is false, we won't see any results.
```js ```js
let isRaining = true let isRaining = true;
if (isRaining) { if (isRaining) {
console.log('Remember to take your rain coat.') console.log('Remember to take your rain coat.');
} }
``` ```
@ -93,46 +94,46 @@ if (condition) {
``` ```
```js ```js
let num = 3 let num = 3;
if (num > 0) { if (num > 0) {
console.log(`${num} is a positive number`) console.log(`${num} is a positive number`);
} else { } else {
console.log(`${num} is a negative number`) console.log(`${num} is a negative number`);
} }
// 3 is a positive number // 3 is a positive number
num = -3 num = -3;
if (num > 0) { if (num > 0) {
console.log(`${num} is a positive number`) console.log(`${num} is a positive number`);
} else { } else {
console.log(`${num} is a negative number`) console.log(`${num} is a negative number`);
} }
// -3 is a negative number // -3 is a negative number
``` ```
```js ```js
let isRaining = true let isRaining = true;
if (isRaining) { if (isRaining) {
console.log('You need a rain coat.') console.log('You need a rain coat.');
} else { } else {
console.log('No need for a rain coat.') console.log('No need for a rain coat.');
} }
// You need a rain coat. // You need a rain coat.
isRaining = false isRaining = false;
if (isRaining) { if (isRaining) {
console.log('You need a rain coat.') console.log('You need a rain coat.');
} else { } else {
console.log('No need for a rain coat.') console.log('No need for a rain coat.');
} }
// No need for a rain coat. // No need for a rain coat.
``` ```
The last condition is false, therefore the else block was executed. What if we have more than two conditions? In that case, we would use *else if* conditions. The last condition is false, therefore the else block was executed. What if we have more than two conditions? In that case, we would use _else if_ conditions.
### If Else if Else ### If Else if Else
On our daily life, we make decisions on daily basis. We make decisions not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full of conditions. We use *else if* when we have multiple conditions. On our daily life, we make decisions on daily basis. We make decisions not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full of conditions. We use _else if_ when we have multiple conditions.
```js ```js
// syntax // syntax
@ -142,106 +143,104 @@ if (condition) {
// code // code
} else { } else {
// code // code
} }
``` ```
**Example:** **Example:**
```js ```js
let a = 0 let a = 0;
if (a > 0) { if (a > 0) {
console.log(`${a} is a positive number`) console.log(`${a} is a positive number`);
} else if (a < 0) { } else if (a < 0) {
console.log(`${a} is a negative number`) console.log(`${a} is a negative number`);
} else if (a == 0) { } else if (a == 0) {
console.log(`${a} is zero`) console.log(`${a} is zero`);
} else { } else {
console.log(`${a} is not a number`) console.log(`${a} is not a number`);
} }
``` ```
```js ```js
// if else if else // if else if else
let weather = 'sunny' let weather = 'sunny';
if (weather === 'rainy') { if (weather === 'rainy') {
console.log('You need a rain coat.') console.log('You need a rain coat.');
} else if (weather === 'cloudy') { } else if (weather === 'cloudy') {
console.log('It might be cold, you need a jacket.') console.log('It might be cold, you need a jacket.');
} else if (weather === 'sunny') { } else if (weather === 'sunny') {
console.log('Go out freely.') console.log('Go out freely.');
} else { } else {
console.log('No need for rain coat.') console.log('No need for rain coat.');
} }
``` ```
### Switch ### Switch
Switch is an alternative for **if else if else else**. Switch is an alternative for **if else if else else**.
The switch statement starts with a *switch* keyword followed by a parenthesis and code block. Inside the code block we will have different cases. Case block runs if the value in the switch statement parenthesis matches with the case value. The break statement is to terminate execution so the code execution does not go down after the condition is satisfied. The default block runs if all the cases don't satisfy the condition. The switch statement starts with a _switch_ keyword followed by a parenthesis and code block. Inside the code block we will have different cases. Case block runs if the value in the switch statement parenthesis matches with the case value. The break statement is to terminate execution so the code execution does not go down after the condition is satisfied. The default block runs if all the cases don't satisfy the condition.
```js ```js
switch (caseValue) { switch (caseValue) {
case 1: case 1:
// code // code
break break;
case 2: case 2:
// code // code
break break;
case 3: case 3:
// code // code
break break;
default: default:
// code // code
} }
``` ```
```js ```js
let weather = 'cloudy' let weather = 'cloudy';
switch (weather) { switch (weather) {
case 'rainy': case 'rainy':
console.log('You need a rain coat.') console.log('You need a rain coat.');
break break;
case 'cloudy': case 'cloudy':
console.log('It might be cold, you need a jacket.') console.log('It might be cold, you need a jacket.');
break break;
case 'sunny': case 'sunny':
console.log('Go out freely.') console.log('Go out freely.');
break break;
default: default:
console.log(' No need for rain coat.') console.log(' No need for rain coat.');
} }
// Switch More Examples // Switch More Examples
let dayUserInput = prompt('What day is today ?') let dayUserInput = prompt('What day is today ?');
let day = dayUserInput.toLowerCase() let day = dayUserInput.toLowerCase();
switch (day) { switch (day) {
case 'monday': case 'monday':
console.log('Today is Monday') console.log('Today is Monday');
break break;
case 'tuesday': case 'tuesday':
console.log('Today is Tuesday') console.log('Today is Tuesday');
break break;
case 'wednesday': case 'wednesday':
console.log('Today is Wednesday') console.log('Today is Wednesday');
break break;
case 'thursday': case 'thursday':
console.log('Today is Thursday') console.log('Today is Thursday');
break break;
case 'friday': case 'friday':
console.log('Today is Friday') console.log('Today is Friday');
break break;
case 'saturday': case 'saturday':
console.log('Today is Saturday') console.log('Today is Saturday');
break break;
case 'sunday': case 'sunday':
console.log('Today is Sunday') console.log('Today is Sunday');
break break;
default: default:
console.log('It is not a week day.') console.log('It is not a week day.');
} }
``` ```
// Examples to use conditions in the cases // Examples to use conditions in the cases
@ -268,10 +267,10 @@ switch (true) {
Another way to write conditionals is using ternary operators. We have covered this in other sections, but we should also mention it here. Another way to write conditionals is using ternary operators. We have covered this in other sections, but we should also mention it here.
```js ```js
let isRaining = true let isRaining = true;
isRaining isRaining
? console.log('You need a rain coat.') ? console.log('You need a rain coat.')
: console.log('No need for a rain coat.') : console.log('No need for a rain coat.');
``` ```
🌕 You are extraordinary and you have a remarkable potential. You have just completed day 4 challenges and you are four steps ahead to your way to greatness. Now do some exercises for your brain and muscle. 🌕 You are extraordinary and you have a remarkable potential. You have just completed day 4 challenges and you are four steps ahead to your way to greatness. Now do some exercises for your brain and muscle.
@ -303,8 +302,8 @@ isRaining
- ternary operator. - ternary operator.
```js ```js
let a = 4 let a = 4;
let b = 3 let b = 3;
``` ```
```sh ```sh
@ -323,18 +322,18 @@ isRaining
### Exercises: Level 2 ### Exercises: Level 2
1. Write a code which can give grades to students according to theirs scores: 1. Write a code which can give grades to students according to their scores:
- 80-100, A - 80-100, A
- 70-89, B - 70-79, B
- 60-69, C - 60-69, C
- 50-59, D - 50-59, D
- 0-49, F - 0-49, F
1. Check if the season is Autumn, Winter, Spring or Summer. 1. Check if the season is Autumn, Winter, Spring or Summer.
If the user input is : If the user input is :
- September, October or November, the season is Autumn. - September, October, or November, the season is Autumn.
- December, January or February, the season is Winter. - December, January, or February, the season is Winter.
- March, April or May, the season is Spring - March, April, or May, the season is Spring
- June, July or August, the season is Summer - June, July, or August, the season is Summer
1. Check if a day is weekend day or a working day. Your script will take day as an input. 1. Check if a day is weekend day or a working day. Your script will take day as an input.
```sh ```sh
@ -371,7 +370,6 @@ isRaining
1. Write a program which tells the number of days in a month, now consider leap year. 1. Write a program which tells the number of days in a month, now consider leap year.
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉
[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) [<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md)

Loading…
Cancel
Save