You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 05_Day/05_day_arrays.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,13 +35,13 @@
35
35
36
36
## Arrays
37
37
38
-
In contrast to variablesarray 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.
38
+
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.
39
39
40
-
Array is a collection of different data types which are ordered and changeable(modifiable). Allows duplicate element and different data types. An array can be empty or it may have different data type values
40
+
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.
41
41
42
42
### How to create an empty array
43
43
44
-
In JavaScript we can create array in different ways. Let us different ways to create an array.
44
+
In JavaScript, we can create an array in different ways. Let us different ways to create an array.
45
45
46
46
- Using Array constructor
47
47
@@ -125,7 +125,7 @@ console.log(arr)
125
125
126
126
### Creating an array using split
127
127
128
-
As we have seen in earlier section, we can split a string at different position and we can change to an array. Let us see the examples blow.
128
+
As we have seen in the earlier section, we can split a string at different positions, and we can change to an array. Let us see the examples below.
129
129
130
130
```js
131
131
let js ='JavaScript'
@@ -148,7 +148,7 @@ console.log(words)
148
148
149
149
### Accessing array items using index
150
150
151
-
We access each element in an array using their index. An array index start from 0. The picture below show clearly the starting of the index.
151
+
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.
An array is mutable(modifiable). Once an array is created we can modify the contents or the array elements.
250
+
An array is mutable(modifiable). Once an array is created, we can modify the contents of the array elements.
251
251
252
252
```js
253
253
constnumbers= [1, 2, 3, 4, 5]
@@ -283,7 +283,7 @@ console.log(countries)
283
283
284
284
### Methods to manipulate array
285
285
286
-
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_
286
+
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_
287
287
288
288
#### Array Constructor
289
289
@@ -305,13 +305,13 @@ fill: Fill all the array elements with a static value
305
305
constarr=Array() // creates an an empty array
306
306
console.log(arr)
307
307
308
-
consteightXvalues=Array(8).fill('X') // it creates eight element values
308
+
consteightXvalues=Array(8).fill('X') // it creates eight element values filled with 'X'
join:Tojoin 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.
458
+
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.
sort: arrange array elements in ascending order. Sort takes a call back function, we wil see how we use sort with call back function in the coming sections.
594
+
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.
0 commit comments