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 132693a35c..cd3534ca77 100644 --- a/index.js +++ b/index.js @@ -1 +1,36 @@ -// Write your solution here! +let 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.concat(name) +} + +function prependCat(name){ + return [name, ...cats ]; +} + +console.log(prependCat("Arnold")) + +function removeLastCat(name){ + return cats.slice(0,2) + +} + function removeFirstCat(name){ + return cats.slice(1) + } + console.log(removeFirstCat("Arnold"))