From a12d4decee28de193ff8f0a9ef38cc42fb2ee615 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Thu, 15 Feb 2024 18:43:55 -0500 Subject: [PATCH 1/8] Completed assignment --- .results.json | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 38 ++++++++++++- 2 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 .results.json diff --git a/.results.json b/.results.json new file mode 100644 index 0000000000..6cd4f306f7 --- /dev/null +++ b/.results.json @@ -0,0 +1,144 @@ +{ + "stats": { + "suites": 11, + "tests": 9, + "passes": 9, + "pending": 0, + "failures": 0, + "start": "2024-02-15T23:43:08.124Z", + "end": "2024-02-15T23:43:08.323Z", + "duration": 199 + }, + "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": 0, + "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": 1, + "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": 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": {} + } + ], + "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": 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": 0, + "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": 1, + "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": 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": {} + } + ] +} \ No newline at end of file diff --git a/index.js b/index.js index 132693a35c..33ce24660c 100644 --- a/index.js +++ b/index.js @@ -1 +1,37 @@ -// Write your solution here! +const cats = [ + "Milo", + "Otis", + "Garfield", +] + +function destructivelyAppendCat(name) { + return cats.push(name); +} + +function destructivelyPrependCat(name) { + return cats.unshift(name); +} + +function destructivelyRemoveLastCat(name) { + return cats.pop(name); +} + +function destructivelyRemoveFirstCat(name) { + return cats.shift(name); +} + +function appendCat(name) { + return [...cats, name]; +} + +function prependCat(name) { + return [name, ...cats]; +} + +function removeLastCat() { + return cats.slice(0, cats.length - 1); +} + +function removeFirstCat() { + return cats.slice(1); +} \ No newline at end of file From e72a6f1ebfca2d1352ec21d0ebfb039bbc71e4f3 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:53:28 -0400 Subject: [PATCH 2/8] Remove previous solutions --- index.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/index.js b/index.js index 33ce24660c..e69de29bb2 100644 --- a/index.js +++ b/index.js @@ -1,37 +0,0 @@ -const cats = [ - "Milo", - "Otis", - "Garfield", -] - -function destructivelyAppendCat(name) { - return cats.push(name); -} - -function destructivelyPrependCat(name) { - return cats.unshift(name); -} - -function destructivelyRemoveLastCat(name) { - return cats.pop(name); -} - -function destructivelyRemoveFirstCat(name) { - return cats.shift(name); -} - -function appendCat(name) { - return [...cats, name]; -} - -function prependCat(name) { - return [name, ...cats]; -} - -function removeLastCat() { - return cats.slice(0, cats.length - 1); -} - -function removeFirstCat() { - return cats.slice(1); -} \ No newline at end of file From 01945b4341b35e83af06e9684efaee8395d86c62 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:55:26 -0400 Subject: [PATCH 3/8] Destructively append names to cats array --- .results.json | 123 ++++++++++++++++++++++++++++++++++---------------- index.js | 5 ++ 2 files changed, 88 insertions(+), 40 deletions(-) diff --git a/.results.json b/.results.json index 6cd4f306f7..8a7a00af27 100644 --- a/.results.json +++ b/.results.json @@ -2,12 +2,12 @@ "stats": { "suites": 11, "tests": 9, - "passes": 9, + "passes": 2, "pending": 0, - "failures": 0, - "start": "2024-02-15T23:43:08.124Z", - "end": "2024-02-15T23:43:08.323Z", - "duration": 199 + "failures": 7, + "start": "2025-05-06T16:55:00.754Z", + "end": "2025-05-06T16:55:00.859Z", + "duration": 105 }, "tests": [ { @@ -29,114 +29,157 @@ "fullTitle": "index.js Array functions destructivelyPrependCat(name) prepends a cat to the beginning of the cats array", "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: destructivelyPrependCat is not defined\n at Context. (test/indexTest.js:27:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyPrependCat is not defined" + } }, { "title": "removes the last cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: destructivelyRemoveLastCat is not defined\n at Context. (test/indexTest.js:35:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyRemoveLastCat is not defined" + } }, { "title": "removes the first cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array", - "duration": 1, + "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: destructivelyRemoveFirstCat is not defined\n at Context. (test/indexTest.js:43:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyRemoveFirstCat is not defined" + } }, { "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": {} + "err": { + "stack": "ReferenceError: appendCat is not defined\n at Context. (test/indexTest.js:51:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "appendCat is not defined" + } }, { "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, + "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: prependCat is not defined\n at Context. (test/indexTest.js:59:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "prependCat is not defined" + } }, { "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": {} + "err": { + "stack": "ReferenceError: removeLastCat is not defined\n at Context. (test/indexTest.js:67:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "removeLastCat is not defined" + } }, { "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, + "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: removeFirstCat is not defined\n at Context. (test/indexTest.js:75:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "removeFirstCat is not defined" + } } ], "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": 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": {} - }, + "failures": [ { "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": {} + "err": { + "stack": "ReferenceError: destructivelyPrependCat is not defined\n at Context. (test/indexTest.js:27:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyPrependCat is not defined" + } }, { "title": "removes the last cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: destructivelyRemoveLastCat is not defined\n at Context. (test/indexTest.js:35:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyRemoveLastCat is not defined" + } }, { "title": "removes the first cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array", - "duration": 1, + "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: destructivelyRemoveFirstCat is not defined\n at Context. (test/indexTest.js:43:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "destructivelyRemoveFirstCat is not defined" + } }, { "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": {} + "err": { + "stack": "ReferenceError: appendCat is not defined\n at Context. (test/indexTest.js:51:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "appendCat is not defined" + } }, { "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, + "duration": 0, "currentRetry": 0, - "err": {} + "err": { + "stack": "ReferenceError: prependCat is not defined\n at Context. (test/indexTest.js:59:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "prependCat is not defined" + } }, { "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": {} + "err": { + "stack": "ReferenceError: removeLastCat is not defined\n at Context. (test/indexTest.js:67:9)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "removeLastCat is not defined" + } }, { "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, + "duration": 0, + "currentRetry": 0, + "err": { + "stack": "ReferenceError: removeFirstCat is not defined\n at Context. (test/indexTest.js:75:9)\n at process.processImmediate (node:internal/timers:478: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": 0, "currentRetry": 0, "err": {} } diff --git a/index.js b/index.js index e69de29bb2..517b024a2f 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,5 @@ +const cats = ["Milo", "Otis", "Garfield"]; + +function destructivelyAppendCat(name) { + return cats.push(name); +} \ No newline at end of file From 6282c002e5e9ef6f1f23673f9fe217862e6694f1 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:56:10 -0400 Subject: [PATCH 4/8] Destructively prepend names to cats array --- .results.json | 30 ++++++++++++------------------ index.js | 4 ++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.results.json b/.results.json index 8a7a00af27..77227e2630 100644 --- a/.results.json +++ b/.results.json @@ -2,11 +2,11 @@ "stats": { "suites": 11, "tests": 9, - "passes": 2, + "passes": 3, "pending": 0, - "failures": 7, - "start": "2025-05-06T16:55:00.754Z", - "end": "2025-05-06T16:55:00.859Z", + "failures": 6, + "start": "2025-05-06T16:55:48.906Z", + "end": "2025-05-06T16:55:49.011Z", "duration": 105 }, "tests": [ @@ -29,10 +29,7 @@ "fullTitle": "index.js Array functions destructivelyPrependCat(name) prepends a cat to the beginning of the cats array", "duration": 0, "currentRetry": 0, - "err": { - "stack": "ReferenceError: destructivelyPrependCat is not defined\n at Context. (test/indexTest.js:27:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyPrependCat is not defined" - } + "err": {} }, { "title": "removes the last cat from the cats array", @@ -97,16 +94,6 @@ ], "pending": [], "failures": [ - { - "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": { - "stack": "ReferenceError: destructivelyPrependCat is not defined\n at Context. (test/indexTest.js:27:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyPrependCat is not defined" - } - }, { "title": "removes the last cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", @@ -182,6 +169,13 @@ "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": {} } ] } \ No newline at end of file diff --git a/index.js b/index.js index 517b024a2f..efb8dd5494 100644 --- a/index.js +++ b/index.js @@ -2,4 +2,8 @@ const cats = ["Milo", "Otis", "Garfield"]; function destructivelyAppendCat(name) { return cats.push(name); +} + +function destructivelyPrependCat(name) { + return cats.unshift(name); } \ No newline at end of file From 068fa13aa0e723b843a7808a9f1a8733c4265cb8 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:57:11 -0400 Subject: [PATCH 5/8] Destructively remove last name from cats array --- .results.json | 36 +++++++++++++++--------------------- index.js | 4 ++++ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.results.json b/.results.json index 77227e2630..60c1535d69 100644 --- a/.results.json +++ b/.results.json @@ -2,18 +2,18 @@ "stats": { "suites": 11, "tests": 9, - "passes": 3, + "passes": 4, "pending": 0, - "failures": 6, - "start": "2025-05-06T16:55:48.906Z", - "end": "2025-05-06T16:55:49.011Z", - "duration": 105 + "failures": 5, + "start": "2025-05-06T16:56:51.184Z", + "end": "2025-05-06T16:56:51.286Z", + "duration": 102 }, "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, + "duration": 1, "currentRetry": 0, "err": {} }, @@ -36,10 +36,7 @@ "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", "duration": 0, "currentRetry": 0, - "err": { - "stack": "ReferenceError: destructivelyRemoveLastCat is not defined\n at Context. (test/indexTest.js:35:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyRemoveLastCat is not defined" - } + "err": {} }, { "title": "removes the first cat from the cats array", @@ -94,16 +91,6 @@ ], "pending": [], "failures": [ - { - "title": "removes the last cat from the cats array", - "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", - "duration": 0, - "currentRetry": 0, - "err": { - "stack": "ReferenceError: destructivelyRemoveLastCat is not defined\n at Context. (test/indexTest.js:35:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyRemoveLastCat is not defined" - } - }, { "title": "removes the first cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array", @@ -159,7 +146,7 @@ { "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, + "duration": 1, "currentRetry": 0, "err": {} }, @@ -176,6 +163,13 @@ "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": 0, + "currentRetry": 0, + "err": {} } ] } \ No newline at end of file diff --git a/index.js b/index.js index efb8dd5494..f65ee5defb 100644 --- a/index.js +++ b/index.js @@ -6,4 +6,8 @@ function destructivelyAppendCat(name) { function destructivelyPrependCat(name) { return cats.unshift(name); +} + +function destructivelyRemoveLastCat() { + return cats.pop(); } \ No newline at end of file From ada0854b9e8f3fc065a85932f8228260c3713812 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:57:49 -0400 Subject: [PATCH 6/8] Destructively remove first name from cats array --- .results.json | 36 +++++++++++++++--------------------- index.js | 4 ++++ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.results.json b/.results.json index 60c1535d69..71dc9a4ca2 100644 --- a/.results.json +++ b/.results.json @@ -2,18 +2,18 @@ "stats": { "suites": 11, "tests": 9, - "passes": 4, + "passes": 5, "pending": 0, - "failures": 5, - "start": "2025-05-06T16:56:51.184Z", - "end": "2025-05-06T16:56:51.286Z", - "duration": 102 + "failures": 4, + "start": "2025-05-06T16:57:34.964Z", + "end": "2025-05-06T16:57:35.069Z", + "duration": 105 }, "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": 1, + "duration": 0, "currentRetry": 0, "err": {} }, @@ -43,10 +43,7 @@ "fullTitle": "index.js Array functions destructivelyRemoveFirstCat() removes the first cat from the cats array", "duration": 0, "currentRetry": 0, - "err": { - "stack": "ReferenceError: destructivelyRemoveFirstCat is not defined\n at Context. (test/indexTest.js:43:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyRemoveFirstCat is not defined" - } + "err": {} }, { "title": "appends a cat to the cats array and returns a new array, leaving the cats array unchanged", @@ -91,16 +88,6 @@ ], "pending": [], "failures": [ - { - "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": { - "stack": "ReferenceError: destructivelyRemoveFirstCat is not defined\n at Context. (test/indexTest.js:43:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "destructivelyRemoveFirstCat is not defined" - } - }, { "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", @@ -146,7 +133,7 @@ { "title": "is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]", "fullTitle": "index.js cats is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]", - "duration": 1, + "duration": 0, "currentRetry": 0, "err": {} }, @@ -170,6 +157,13 @@ "duration": 0, "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": {} } ] } \ No newline at end of file diff --git a/index.js b/index.js index f65ee5defb..5e62b2a846 100644 --- a/index.js +++ b/index.js @@ -10,4 +10,8 @@ function destructivelyPrependCat(name) { function destructivelyRemoveLastCat() { return cats.pop(); +} + +function destructivelyRemoveFirstCat() { + return cats.shift(); } \ No newline at end of file From 981bca2c666a99987ef86c0bff2288cb9dbfa35c Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 12:59:11 -0400 Subject: [PATCH 7/8] Append and prepend names to new array --- .results.json | 58 ++++++++++++++++++++------------------------------- index.js | 8 +++++++ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.results.json b/.results.json index 71dc9a4ca2..a229161a14 100644 --- a/.results.json +++ b/.results.json @@ -2,12 +2,12 @@ "stats": { "suites": 11, "tests": 9, - "passes": 5, + "passes": 7, "pending": 0, - "failures": 4, - "start": "2025-05-06T16:57:34.964Z", - "end": "2025-05-06T16:57:35.069Z", - "duration": 105 + "failures": 2, + "start": "2025-05-06T16:59:01.109Z", + "end": "2025-05-06T16:59:01.213Z", + "duration": 104 }, "tests": [ { @@ -34,7 +34,7 @@ { "title": "removes the last cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", - "duration": 0, + "duration": 1, "currentRetry": 0, "err": {} }, @@ -50,20 +50,14 @@ "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": { - "stack": "ReferenceError: appendCat is not defined\n at Context. (test/indexTest.js:51:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "appendCat is not defined" - } + "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": { - "stack": "ReferenceError: prependCat is not defined\n at Context. (test/indexTest.js:59:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "prependCat is not defined" - } + "err": {} }, { "title": "removes the last cat in the cats array and returns a new array, leaving the cats array unchanged", @@ -88,26 +82,6 @@ ], "pending": [], "failures": [ - { - "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": { - "stack": "ReferenceError: appendCat is not defined\n at Context. (test/indexTest.js:51:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "appendCat is not defined" - } - }, - { - "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": { - "stack": "ReferenceError: prependCat is not defined\n at Context. (test/indexTest.js:59:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "prependCat is not defined" - } - }, { "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", @@ -154,7 +128,7 @@ { "title": "removes the last cat from the cats array", "fullTitle": "index.js Array functions destructivelyRemoveLastCat() removes the last cat from the cats array", - "duration": 0, + "duration": 1, "currentRetry": 0, "err": {} }, @@ -164,6 +138,20 @@ "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": {} } ] } \ No newline at end of file diff --git a/index.js b/index.js index 5e62b2a846..f89c421d0a 100644 --- a/index.js +++ b/index.js @@ -14,4 +14,12 @@ function destructivelyRemoveLastCat() { function destructivelyRemoveFirstCat() { return cats.shift(); +} + +function appendCat(name) { + return [...cats, name]; +} + +function prependCat(name) { + return [name, ...cats]; } \ No newline at end of file From 755ffd40b24559b41741652a38ab1c0aa241d388 Mon Sep 17 00:00:00 2001 From: Emily Kanarek Date: Tue, 6 May 2025 13:06:19 -0400 Subject: [PATCH 8/8] Non-destructively remove first or last cat from array --- .results.json | 61 ++++++++++++++++++++------------------------------- index.js | 8 +++++++ 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/.results.json b/.results.json index a229161a14..7adb22d5e7 100644 --- a/.results.json +++ b/.results.json @@ -2,12 +2,12 @@ "stats": { "suites": 11, "tests": 9, - "passes": 7, + "passes": 9, "pending": 0, - "failures": 2, - "start": "2025-05-06T16:59:01.109Z", - "end": "2025-05-06T16:59:01.213Z", - "duration": 104 + "failures": 0, + "start": "2025-05-06T17:06:00.217Z", + "end": "2025-05-06T17:06:00.322Z", + "duration": 105 }, "tests": [ { @@ -34,7 +34,7 @@ { "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, + "duration": 0, "currentRetry": 0, "err": {} }, @@ -64,45 +64,18 @@ "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": { - "stack": "ReferenceError: removeLastCat is not defined\n at Context. (test/indexTest.js:67:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "removeLastCat is not defined" - } + "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": 0, "currentRetry": 0, - "err": { - "stack": "ReferenceError: removeFirstCat is not defined\n at Context. (test/indexTest.js:75:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "removeFirstCat is not defined" - } + "err": {} } ], "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": 0, - "currentRetry": 0, - "err": { - "stack": "ReferenceError: removeLastCat is not defined\n at Context. (test/indexTest.js:67:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "removeLastCat is not defined" - } - }, - { - "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. (test/indexTest.js:75:9)\n at process.processImmediate (node:internal/timers:478:21)", - "message": "removeFirstCat is not defined" - } - } - ], + "failures": [], "passes": [ { "title": "is assigned an initial value of [\"Milo\", \"Otis\", \"Garfield\"]", @@ -128,7 +101,7 @@ { "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, + "duration": 0, "currentRetry": 0, "err": {} }, @@ -152,6 +125,20 @@ "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": 0, + "currentRetry": 0, + "err": {} } ] } \ No newline at end of file diff --git a/index.js b/index.js index f89c421d0a..8b3db389b5 100644 --- a/index.js +++ b/index.js @@ -22,4 +22,12 @@ function appendCat(name) { function prependCat(name) { return [name, ...cats]; +} + +function removeLastCat() { + return cats.slice(0, cats.length - 1); +} + +function removeFirstCat() { + return cats.slice(1); } \ No newline at end of file