Skip to content

Commit 91d8751

Browse files
committed
day 5:arrays - reviewed
1 parent aad0bcb commit 91d8751

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

05_Day/05_day_arrays.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
![Day 5](../images/banners/day_1_5.png)
1919

20-
- [📔 Day 5](#%f0%9f%93%94-day-5)
20+
- [📔 Day 5](#-day-5)
2121
- [Arrays](#arrays)
2222
- [How to create an empty array](#how-to-create-an-empty-array)
2323
- [How to create an array with values](#how-to-create-an-array-with-values)
@@ -43,7 +43,7 @@
4343
- [Reversing array order](#reversing-array-order)
4444
- [Sorting elements in array](#sorting-elements-in-array)
4545
- [Array of arrays](#array-of-arrays)
46-
- [💻 Exercise](#%f0%9f%92%bb-exercise)
46+
- [💻 Exercise](#-exercise)
4747
- [Exercise: Level 1](#exercise-level-1)
4848
- [Exercise: Level 2](#exercise-level-2)
4949
- [Exercise: Level 3](#exercise-level-3)
@@ -52,14 +52,14 @@
5252

5353
## Arrays
5454

55-
In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the last element is less by one from the length of the array.
55+
In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the index of the last element is less by one from the length of the array.
5656

5757
An array is a collection of different data types which are ordered and changeable(modifiable). An array allows storing duplicate elements and different data types. An array can be empty, or it may have different data type values.
5858

5959
### How to create an empty array
6060

61-
In JavaScript, we can create an array in different ways. Let us different ways to create an array.
62-
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 name again.
61+
In JavaScript, we can create an array in different ways. Let us see different ways to create an array.
62+
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.
6363

6464
- Using Array constructor
6565

@@ -166,7 +166,7 @@ console.log(words)
166166

167167
### Accessing array items using index
168168

169-
We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the starting of the index.
169+
We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the index of each element in the array.
170170

171171
![arr index](../images/array_index.png)
172172

@@ -474,7 +474,7 @@ console.log(names.toString()) // Asabeneh,Mathias,Elias,Brook
474474

475475
#### Joining array elements
476476

477-
join: It used to join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items.
477+
join: It is used to join the elements of the array, the argument we passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items.
478478

479479
```js
480480
const numbers = [1, 2, 3, 4, 5]
@@ -532,8 +532,8 @@ Splice: It takes three parameters:Starting position, number of times to be remov
532532
```
533533

534534
```js
535-
const numbers = [1, 2, 3, 4, 5];
536-
console.log(numbers.splice(3, 3, 6, 7, 8)) // -> [1, 2, 3, 6, 7, 8] //it removes two item and replace three items
535+
const numbers = [1, 2, 3, 4, 5, 6];
536+
console.log(numbers.splice(3, 3, 7, 8, 9)) // -> [1, 2, 3, 7, 8, 9] //it removes three item and replace three items
537537
```
538538

539539
#### Adding item to an array using push
@@ -618,7 +618,7 @@ console.log(numbers) // [1, 2, 3, 4, 5]
618618

619619
#### Sorting elements in array
620620

621-
sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with call back function in the coming sections.
621+
sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with a call back function in the coming sections.
622622

623623
```js
624624
const webTechs = [
@@ -691,33 +691,33 @@ const webTechs = [
691691
```
692692

693693
1. Declare an _empty_ array;
694-
1. Declare an array with more than 5 number of elements
695-
1. Find the length of your array
696-
1. Get the first item, the middle item and the last item of the array
697-
1. Declare an array called _mixedDataTypes_,put different data types in your array and find length of the array. You are should size be greater than 5
698-
1. Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon
699-
1. Print the array using _console.log()_
700-
1. Print the number of companies in the array
701-
1. Print the first company, middle and last company
702-
1. Print out each company
703-
1. Change each company name to uppercase one by one and print them out
704-
1. Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.
705-
1. Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is _not found_
706-
1. Filter out companies which have more than one 'o' without the filter method
707-
1. Sort the array using _sort()_ method
708-
1. Reverse the array using _reverse()_ method
709-
1. Slice out the first 3 companies from the array
710-
1. Slice out the last 3 companies from the array
711-
1. Slice out the middle IT company or companies from the array
712-
1. Remove the first IT company from the array
713-
1. Remove the middle IT company or companies from the array
714-
1. Remove the last IT company from the array
715-
1. Remove all IT companies
694+
2. Declare an array with more than 5 number of elements
695+
3. Find the length of your array
696+
4. Get the first item, the middle item and the last item of the array
697+
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
698+
6. Declare an array variable name itCompanies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon
699+
7. Print the array using _console.log()_
700+
8. Print the number of companies in the array
701+
9. Print the first company, middle and last company
702+
10. Print out each company
703+
11. Change each company name to uppercase one by one and print them out
704+
12. Print the array like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.
705+
13. Check if a certain company exists in the itCompanies array. If it exist return the company else return a company is _not found_
706+
14. Filter out companies which have more than one 'o' without the filter method
707+
15. Sort the array using _sort()_ method
708+
16. Reverse the array using _reverse()_ method
709+
17. Slice out the first 3 companies from the array
710+
18. Slice out the last 3 companies from the array
711+
19. Slice out the middle IT company or companies from the array
712+
20. Remove the first IT company from the array
713+
21. Remove the middle IT company or companies from the array
714+
22. Remove the last IT company from the array
715+
23. Remove all IT companies
716716

717717
### Exercise: Level 2
718718

719-
1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js ans store the webTechs array in to this file. Access both file in main.js file
720-
1. First remove all the functions and change the string to array and count the number of words in the array
719+
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
720+
1. First remove all the punctuations and change the string to array and count the number of words in the array
721721

722722
```js
723723
let text =
@@ -738,10 +738,10 @@ const webTechs = [
738738
const shoppingCart = ['Milk', 'Coffee', 'Tea', 'Honey']
739739
```
740740

741-
- add 'Meat' in the beginning of your shopping cart if if it has not be already added
742-
- add sugar at the end of you shopping cart if it has not been already added
743-
- Remove 'Honey' if you are allergic to honey
744-
- modify tea to 'Green Tea'
741+
- add 'Meat' in the beginning of your shopping cart if it has not been already added
742+
- add Sugar at the end of you shopping cart if it has not been already added
743+
- remove 'Honey' if you are allergic to honey
744+
- modify Tea to 'Green Tea'
745745
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.
746746
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.
747747
1. Concatenate the following two variables and store it in a fullStack variable.

0 commit comments

Comments
 (0)