Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
// Write your solution here!
const cats = ["Milo", "Otis", "Garfield"];

destructivelyAppendCat = (name) => cats.push(name);

destructivelyPrependCat = (name) => cats.unshift(name);

destructivelyRemoveLastCat = (name) => cats.pop(name);

destructivelyRemoveFirstCat = (name) => cats.shift(name);

function appendCat(name) {
let copyOfAppendCat;
return (copyOfAppendCat = [...cats, name]);
}

function prependCat(name) {
let copyOfPrependCat;
return (copyOfPrependCat = [name, ...cats]);
}

function removeLastCat() {
let copyOfRemoveLastCat;
return (copyOfRemoveLastCat = cats.slice(0, cats.length - 1));
}

function removeFirstCat() {
let copyOfRemoveFirstCat;
return (copyOfRemoveFirstCat = cats.slice(1));
}