-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit tree 8656f76bd43ba116c8adc41700d63b000092326b
- Loading branch information
1 parent
e66a501
commit f832268
Showing
2 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"stats": { | ||
"suites": 11, | ||
"tests": 9, | ||
"passes": 7, | ||
"pending": 0, | ||
"failures": 2, | ||
"start": "2022-08-13T10:42:40.013Z", | ||
"end": "2022-08-13T10:42:40.263Z", | ||
"duration": 250 | ||
}, | ||
"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": 1, | ||
"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": 1, | ||
"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": { | ||
"message": "expected [ 'Garfield' ] to have the same ordered members as [ 'Milo', 'Otis' ]", | ||
"showDiff": true, | ||
"actual": "[\n \"Garfield\"\n]", | ||
"expected": "[\n \"Milo\"\n \"Otis\"\n]", | ||
"stack": "AssertionError: expected [ 'Garfield' ] to have the same ordered members as [ 'Milo', 'Otis' ]\n at Context.<anonymous> (test/indexTest.js:65:49)\n at processImmediate (node:internal/timers:466:21)" | ||
} | ||
}, | ||
{ | ||
"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": 0, | ||
"currentRetry": 0, | ||
"err": { | ||
"stack": "ReferenceError: removeFirstCat is not defined\n at Context.<anonymous> (test/indexTest.js:73:9)\n at processImmediate (node:internal/timers:466:21)", | ||
"message": "removeFirstCat is not defined" | ||
} | ||
} | ||
], | ||
"pending": [], | ||
"failures": [ | ||
{ | ||
"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": { | ||
"message": "expected [ 'Garfield' ] to have the same ordered members as [ 'Milo', 'Otis' ]", | ||
"showDiff": true, | ||
"actual": "[\n \"Garfield\"\n]", | ||
"expected": "[\n \"Milo\"\n \"Otis\"\n]", | ||
"stack": "AssertionError: expected [ 'Garfield' ] to have the same ordered members as [ 'Milo', 'Otis' ]\n at Context.<anonymous> (test/indexTest.js:65:49)\n at processImmediate (node:internal/timers:466:21)" | ||
} | ||
}, | ||
{ | ||
"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": 0, | ||
"currentRetry": 0, | ||
"err": { | ||
"stack": "ReferenceError: removeFirstCat is not defined\n at Context.<anonymous> (test/indexTest.js:73:9)\n at processImmediate (node:internal/timers:466:21)", | ||
"message": "removeFirstCat is not defined" | ||
} | ||
} | ||
], | ||
"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": 1, | ||
"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": 1, | ||
"currentRetry": 0, | ||
"err": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
// 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.slice(-1)]; | ||
return newCats; | ||
} |