-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (34 loc) · 736 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
// Write your solution here!
let cats = ["Milo", "Otis", "Garfield"];
function destructivelyAppendCat (name) {
cats.push("Ralph")
}
function destructivelyPrependCat(name){
cats.unshift("Bob")
}
function destructivelyRemoveLastCat(){
cats.pop()
}
function destructivelyRemoveFirstCat(){
cats.shift()
}
function appendCat(name){
const newCats = cats.slice();
newCats.push("Broom");
return newCats;
}
function prependCat(name) {
const newCats = cats.slice();
newCats.unshift("Arnold");
return newCats;
}
function removeLastCat(){
newCats = cats.slice();
newCats.pop();
return newCats;
}
function removeFirstCat(){
const newCats = cats.slice();
newCats.shift();
return newCats;
}