forked from DouglasHdezT/JavaScript_NodeCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample1.js
More file actions
55 lines (37 loc) · 1.06 KB
/
Example1.js
File metadata and controls
55 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Push, pop, unshift, shift
*/
let array1 = [9, 5, 6, 3];
let array2 = [1, 2, 3, 4, 5];
/**
* Push and pop, adds and remove items at the end of the array respectively
*/
const manageArrayAtTheEnd = () => {
console.log("Manage Array at end ");
console.log("Pushing one element");
array1.push(3);
console.log(array1);
console.log("Pushing several elements");
array1.push(2,4,3,5,2);
console.log(array1);
console.log("Poping one element");
console.log(array1.pop());
console.log(array1);
}
/**
* Shift and unshift adds and remove items at the begin of the array respectively
*/
const manageArrayAtTheBegin = () => {
console.log("manage Array at the begin");
console.log("Unshift one element");
array2.unshift(4)
console.log(array2);
console.log("Unshifting several elements");
array2.unshift(6,4,3,5,2);
console.log(array2);
console.log("shift one element");
console.log(array2.shift());
console.log(array2);
}
manageArrayAtTheEnd();
manageArrayAtTheBegin();