-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday33.js
53 lines (33 loc) · 788 Bytes
/
day33.js
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
// program to empty an array
function emptyArray(arr) {
// substituting new array
arr = [];
return arr;
}
const array = [1, 2 ,3];
console.log(array);
// call the function
const result = emptyArray(array);
console.log(result);
// program to append an object to an array
function emptyArray(arr) {
// substituting new array
arr.splice(0, arr.length);
return arr;
}
const array = [1, 2 ,3];
console.log(array);
// call the function
const result = emptyArray(array);
console.log(result);
// program to empty an array
function emptyArray(arr) {
// setting array length to 0
arr.length = 0;
return arr;
}
const array = [1, 2 ,3];
console.log(array);
// call the function
const result = emptyArray(array);
console.log(result);