some cleaning

pull/21/head
Asabeneh 5 years ago
parent b6a158d0e9
commit 48ad1d6cf5

@ -9,7 +9,7 @@
- [Conditionals](#conditionals)
- [if](#if)
- [if else](#if-else)
- [if else if else](#if-else-if-else)
- [if else if else else](#if-else-if-else-else)
- [Switch](#switch)
- [Ternary Operators](#ternary-operators)
- [💻 Exercise : Conditionals](#%f0%9f%92%bb-exercise--conditionals)
@ -113,7 +113,7 @@ if (isRaining) {
The above condition is false, therefore the else block was executed. How about if our condition is more than two, we will use *else if* conditions.
### if else if else
### if else if else else
On our daily life, we make decision on daily basis. We make decision 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 conditions. We use *else if* when we have multiple conditions.

@ -129,15 +129,18 @@ As we have seen in earlier section, we can split a string at different position
```js
let js = 'JavaScript'
const charsInJavaScript = js.split('') // ["J", "a", "v", "a", "S", "c", "r", "i", "p", "t"]
console.log(charsInJavaScript)
const charsInJavaScript = js.split('')
console.log(charsInJavaScript) // ["J", "a", "v", "a", "S", "c", "r", "i", "p", "t"]
let companiesString = 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon'
const companies = companiesString.split(',')
console.log(companies) // ["Facebook", " Google", " Microsoft", " Apple", " IBM", " Oracle", " Amazon"]
let text =
'I love teaching and empowering people. I teach HTML, CSS, JS, React, Python.'
const words = text.split(' ')
console.log(words)
// the text has special characters think how you can just get only the words
// ["I", "love", "teaching", "and", "empowering", "people.", "I", "teach", "HTML,", "CSS,", "JS,", "React,", "Python"]
@ -152,14 +155,19 @@ We access each element in an array using their index. An array index start from
```js
const fruits = ['banana', 'orange', 'mango', 'lemon']
let firstFruit = fruits[0] // we are accessing the first item using its index
console.log(firstFruit) // banana
secondFruit = fruits[1]
console.log(secondFruit) // orange
lastFruit = fruits[3]
let lastFruit = fruits[3]
console.log(lastFruit) // lemon
// Last index
// Last index can be calculated as follows
let lastIndex = len(fruits) - 1
let lastFruit = fruits[lastIndex]
lastFruit = fruits[lastIndex]
console.log(lastFruit) // lemon
```
```js
@ -258,11 +266,11 @@ const countries = [
'Ireland',
'Japan',
'Kenya'
]
]
countries[0] = 'Afghanistan' // Albania replaced by Afghanistan
countries[0] = 'Afghanistan' // Replacing Albania by Afghanistan
let lastIndex = countries.length - 1
countries[lastIndex] = 'Korea'
countries[lastIndex] = 'Korea' // Replacing Kenya by Korea
console.log(countries)
```

Loading…
Cancel
Save