From b476dda3e4647f592d0ed04c1956d54b94624b9d Mon Sep 17 00:00:00 2001 From: Ben Oluoch Date: Mon, 17 Mar 2025 20:26:43 +0300 Subject: [PATCH 1/2] Group Discussion --- index.js | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 132693a35c..00d07884e9 100644 --- a/index.js +++ b/index.js @@ -1 +1,43 @@ -// Write your solution here! +let cats = [ "Milo", "Otis", "Garfield"]; + +function destructivelyAppendCat(name){ + return cats.push(name) +} + +//TODO: Valentine +function destructivelyPrependCat(name){ + +} + +//TODO: Edith +function destructivelyRemoveLastCat(name){ + +} + +//TODO: Anthony +function destructivelyRemoveFirstCat(name){ + +} + +//TODO: Alvin +function appendCat(name){ + +} + + +//TODO: Neema +function prependCat(name){ + +} + +console.log(prependCat("Arnold")) + + +//TODO: Crispus +function removeLastCat(name){ + +} + function removeFirstCat(name){ + return cats.slice(1) + } + console.log(removeFirstCat("Arnold")) \ No newline at end of file From e7632e4a613a0c91c7ef7ddbe18cfae5ef7531ab Mon Sep 17 00:00:00 2001 From: Ben Oluoch Date: Mon, 24 Mar 2025 15:50:57 +0300 Subject: [PATCH 2/2] Update the code --- .results.json | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 23 +++----- 2 files changed, 152 insertions(+), 15 deletions(-) create mode 100644 .results.json diff --git a/.results.json b/.results.json new file mode 100644 index 0000000000..1e061dabee --- /dev/null +++ b/.results.json @@ -0,0 +1,144 @@ +{ + "stats": { + "suites": 11, + "tests": 9, + "passes": 9, + "pending": 0, + "failures": 0, + "start": "2025-03-17T17:34:22.251Z", + "end": "2025-03-17T17:34:22.497Z", + "duration": 246 + }, + "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, + "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": 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": 0, + "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": 1, + "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": 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": 0, + "currentRetry": 0, + "err": {} + } + ] +} \ No newline at end of file diff --git a/index.js b/index.js index 00d07884e9..cd3534ca77 100644 --- a/index.js +++ b/index.js @@ -4,40 +4,33 @@ function destructivelyAppendCat(name){ return cats.push(name) } -//TODO: Valentine + function destructivelyPrependCat(name){ - + return cats.unshift(name) } -//TODO: Edith function destructivelyRemoveLastCat(name){ - + return cats.pop(name) } -//TODO: Anthony function destructivelyRemoveFirstCat(name){ - + return cats.shift(name) } - -//TODO: Alvin function appendCat(name){ - + return cats.concat(name) } - -//TODO: Neema function prependCat(name){ - + return [name, ...cats ]; } console.log(prependCat("Arnold")) - -//TODO: Crispus function removeLastCat(name){ + return cats.slice(0,2) } function removeFirstCat(name){ return cats.slice(1) } - console.log(removeFirstCat("Arnold")) \ No newline at end of file + console.log(removeFirstCat("Arnold"))