Skip to content

commit tree 17608f2ef78e3d2cc2dbd5b32e8f9aaeef97b25b #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: fis-wip
Choose a base branch
from
Open
Show file tree
Hide file tree
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
144 changes: 144 additions & 0 deletions .results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"stats": {
"suites": 11,
"tests": 9,
"passes": 9,
"pending": 0,
"failures": 0,
"start": "2022-06-08T11:05:26.215Z",
"end": "2022-06-08T11:05:26.863Z",
"duration": 648
},
"tests": [
{
"title": "is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]",
"fullTitle": "index.js cats is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]",
"duration": 2,
"currentRetry": 0,
"err": {}
},
{
"title": "appends a cat to the end of the cats array",
"fullTitle": "index.js Array functions destructivelyAppendCat(name) appends a cat to the end of the cats array",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "prepends a cat to the beginning of the cats array",
"fullTitle": "index.js Array functions destructivelyPrependCat(name) prepends a cat to the beginning of the cats array",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the last cat from the cats array",
"fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array",
"duration": 2,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the first cat from the cats array",
"fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "appends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions appendCat(name) appends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "prepends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions prependCat(name) prepends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the last cat in the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions removeLastCat() removes the last cat in the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the first cat from the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions removeFirstCat() removes the first cat from the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
}
],
"pending": [],
"failures": [],
"passes": [
{
"title": "is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]",
"fullTitle": "index.js cats is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]",
"duration": 2,
"currentRetry": 0,
"err": {}
},
{
"title": "appends a cat to the end of the cats array",
"fullTitle": "index.js Array functions destructivelyAppendCat(name) appends a cat to the end of the cats array",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "prepends a cat to the beginning of the cats array",
"fullTitle": "index.js Array functions destructivelyPrependCat(name) prepends a cat to the beginning of the cats array",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the last cat from the cats array",
"fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array",
"duration": 2,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the first cat from the cats array",
"fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "appends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions appendCat(name) appends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "prepends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions prependCat(name) prepends a cat to the cats array and returns a new array, leaving the cats array unchanged",
"duration": 0,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the last cat in the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions removeLastCat() removes the last cat in the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
},
{
"title": "removes the first cat from the cats array and returns a new array, leaving the cats array unchanged",
"fullTitle": "index.js Array functions removeFirstCat() removes the first cat from the cats array and returns a new array, leaving the cats array unchanged",
"duration": 1,
"currentRetry": 0,
"err": {}
}
]
}
35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
// Write your solution here!
const cats = ["Milo", "Otis", "Garfield"];

function destructivelyAppendCat(Ralph){
return cats.push(Ralph);
}

function destructivelyPrependCat(Bob){
return cats.unshift(Bob);
}

function destructivelyRemoveLastCat(Garfield){
return cats.pop(Garfield);
}

function destructivelyRemoveFirstCat(Milo){
return cats.shift(Milo);
}

function appendCat(Broom){
return [...cats, Broom];
}

function prependCat(Arnold){
return [Arnold, ...cats];
}

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

function removeLastCat(){
return cats.slice(0,2);
}