-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (38 loc) · 822 Bytes
/
index.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
// Write your solution here!
const cats= ['Milo', 'Otis', 'Garfield'];
function destructivelyAppendCat(name){
cats;
console.log(cats.push('Ralph'));
}
function destructivelyPrependCat(name){
cats;
console.log(cats.unshift(name));
}
function destructivelyRemoveLastCat(name){
cats;
console.log(cats.pop(name));
}
function destructivelyRemoveFirstCat(name){
cats;
console.log(cats.shift(name));
}
function appendCat(name){
cats;
const addedCat = [...cats, name];
return addedCat;
}
function prependCat(name){
cats;
const addedCat = [name, ...cats];
return addedCat;
}
function removeLastCat(name){
cats;
const addedCat = cats.slice(0,2);
return addedCat;
}
function removeFirstCat(name){
cats;
const addedCat = cats.slice(1);
return addedCat;
}