Skip to content

Commit

Permalink
commit tree 43a0eb0f8f33e7054478ac748261841895946887
Browse files Browse the repository at this point in the history
  • Loading branch information
TeejayDixon committed Aug 13, 2022
1 parent e66a501 commit f7905bd
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 0 deletions.
155 changes: 155 additions & 0 deletions .results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"stats": {
"suites": 11,
"tests": 9,
"passes": 8,
"pending": 0,
"failures": 1,
"start": "2022-08-13T10:48:26.161Z",
"end": "2022-08-13T10:48:26.405Z",
"duration": 244
},
"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": 0,
"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": 0,
"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": 1,
"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": 0,
"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": 0,
"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": {
"message": "expected 'Milo' to be an array",
"showDiff": false,
"actual": "Milo",
"stack": "AssertionError: expected 'Milo' to be an array\n at Context.<anonymous> (test/indexTest.js:73:50)\n at processImmediate (node:internal/timers:466:21)"
}
}
],
"pending": [],
"failures": [
{
"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": {
"message": "expected 'Milo' to be an array",
"showDiff": false,
"actual": "Milo",
"stack": "AssertionError: expected 'Milo' to be an array\n at Context.<anonymous> (test/indexTest.js:73:50)\n at processImmediate (node:internal/timers:466:21)"
}
}
],
"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": 0,
"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": 0,
"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": 1,
"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": 0,
"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": 0,
"currentRetry": 0,
"err": {}
}
]
}
43 changes: 43 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
// Write your solution here!
const cats = ["Milo", "Otis", "Garfield"];


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

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

destructivelyRemoveLastCat = () => {
return cats.pop(-1);
}

function destructivelyRemoveFirstCat() {
return cats.splice(0, 1);

}

const newCats = [...cats]

function appendCat() {
const newCats = [...cats, "Broom"];
return newCats;
}

function prependCat() {
const preCats = ["Arnold", ...cats];

return preCats;
}


function removeLastCat() {
const newCats = [...cats];
return cats.slice(0, newCats.length -1);
}

function removeFirstCat() {
const oldCats = [...cats];
return oldCats.shift(0);
}

0 comments on commit f7905bd

Please sign in to comment.