fixed some typo and punctuations in day 4 and day 5

pull/759/head
sapiensFactor 2 years ago
parent 4a5b93b3e3
commit 94c8b1dc23

@ -324,7 +324,7 @@ isRaining
### Exercises: Level 2
1. Write a code which can give grades to students according to theirs scores:
- 80-100, A
- 90-100, A
- 70-89, B
- 60-69, C
- 50-59, D

@ -59,7 +59,7 @@ An array is a collection of different data types which are ordered and changeabl
### How to create an empty array
In JavaScript, we can create an array in different ways. Let us see different ways to create an array.
It is very common to use _const_ instead of _let_ to declare an array variable. If you ar using const it means you do not use that variable name again.
It is very common to use _const_ instead of _let_ to declare an array variable. If you are using _const_, it means you do not use that variable name again.
- Using Array constructor
@ -302,11 +302,11 @@ console.log(countries)
### Methods to manipulate array
There are different methods to manipulate an array. These are some of the available methods to deal with arrays:_Array, length, concat, indexOf, slice, splice, join, toString, includes, lastIndexOf, isArray, fill, push, pop, shift, unshift_
There are different methods to manipulate an array. These are some of the available methods to deal with arrays: _Array, length, concat, indexOf, slice, splice, join, toString, includes, lastIndexOf, isArray, fill, push, pop, shift, unshift_
#### Array Constructor
Array:To create an array.
Array: To create an array.
```js
const arr = Array() // creates an an empty array
@ -336,7 +336,7 @@ console.log(four4values) // [4, 4, 4, 4]
#### Concatenating array using concat
concat:To concatenate two arrays.
concat: To concatenate two arrays.
```js
const firstList = [1, 2, 3]
@ -360,16 +360,16 @@ console.log(fruitsAndVegetables)
#### Getting array length
Length:To know the size of the array
Length: To know the size of the array
```js
const numbers = [1, 2, 3, 4, 5]
console.log(numbers.length) // -> 5 is the size of the array
```
#### Getting index an element in arr array
#### Getting index of an element in an array
indexOf:To check if an item exist in an array. If it exists it returns the index else it returns -1.
indexOf: To check if an item exist in an array. If it exists it returns the index else it returns -1.
```js
const numbers = [1, 2, 3, 4, 5]
@ -450,7 +450,7 @@ console.log(webTechs.includes('C')) // false
#### Checking array
Array.isArray:To check if the data type is an array
Array.isArray: To check if the data type is an array
```js
const numbers = [1, 2, 3, 4, 5]
@ -462,7 +462,7 @@ console.log(Array.isArray(number)) // false
#### Converting array to string
toString:Converts array to string
toString: Converts array to string
```js
const numbers = [1, 2, 3, 4, 5]
@ -517,7 +517,7 @@ Slice: To cut out a multiple items in range. It takes two parameters:starting an
#### Splice method in array
Splice: It takes three parameters:Starting position, number of times to be removed and number of items to be added.
Splice: It takes three parameters: Starting position, number of times to be removed and number of items to be added.
```js
const numbers = [1, 2, 3, 4, 5]
@ -653,7 +653,7 @@ console.log(arrayOfArray[0]) // [1, 2, 3]
console.log(fullStack[1]) // ["Node", "Express", "MongoDB"]
```
🌕 You are diligent and you have already achieved quite a lot. You have just completed day 5 challenges and you are 5 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
🌕 You are diligent and you have already achieved quite a lot. You have just completed day 5 challenges and you are 5 steps ahead in to your way to greatness. Now do some exercises for your brain and for your muscle.
## 💻 Exercise
@ -690,15 +690,15 @@ const webTechs = [
3. Find the length of your array
4. Get the first item, the middle item and the last item of the array
5. Declare an array called _mixedDataTypes_, put different data types in the array and find the length of the array. The array size should be greater than 5
6. Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon
6. Declare an array variable named itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon
7. Print the array using _console.log()_
8. Print the number of companies in the array
9. Print the first company, middle and last company
10. Print out each company
11. Change each company name to uppercase one by one and print them out
12. Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.
11. Change each company name to uppercase one by one and print them out
12. Print the array like a sentence: Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon are big IT companies.
13. Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is _not found_
14. Filter out companies which have more than one 'o' without the filter method
14. Filter out company names which have more than one 'o' without the filter method
15. Sort the array using _sort()_ method
16. Reverse the array using _reverse()_ method
17. Slice out the first 3 companies from the array
@ -712,7 +712,7 @@ const webTechs = [
### Exercise: Level 2
1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js and store the webTechs array in to this file. Access both file in main.js file
1. First remove all the punctuations and change the string to array and count the number of words in the array
2. First remove all the punctuations and change the string to array and count the number of words in the array
```js
let text =
@ -738,8 +738,8 @@ const webTechs = [
- remove 'Honey' if you are allergic to honey
- modify Tea to 'Green Tea'
1. In countries array check if 'Ethiopia' exists in the array if it exists print 'ETHIOPIA'. If it does not exist add to the countries list.
1. In the webTechs array check if Sass exists in the array and if it exists print 'Sass is a CSS preprocess'. If it does not exist add Sass to the array and print the array.
1. Concatenate the following two variables and store it in a fullStack variable.
1. In the webTechs array check if 'Sass' exists in the array and if it exists print 'Sass is a CSS preprocess'. If it does not exist add 'Sass' to the array and print the array.
2. Concatenate the following two variables and store it in a fullStack variable.
```js
const frontEnd = ['HTML', 'CSS', 'JS', 'React', 'Redux']
@ -765,10 +765,10 @@ const webTechs = [
- Find the average age(all items divided by number of items)
- Find the range of the ages(max minus min)
- Compare the value of (min - average) and (max - average), use _abs()_ method
1.Slice the first ten countries from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
1. Slice the first ten countries from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
1. Find the middle country(ies) in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
2. Divide the countries array into two equal arrays if it is even. If countries array is not even , one more country for the first half.
2. Divide the countries array into two equal arrays if it is even. If countries array is not even, one more country for the first half.
🎉 CONGRATULATIONS ! 🎉
[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/06_day_loops.md)
[<< Day 4](../04_Day_Conditionals/04_day_conditionals.md)| [Day 6 >>](../06_Day_Loops/06_day_loops.md)

Loading…
Cancel
Save