From ff2f7d34d7c97d8ae67c92c8cc67e377fdd32a12 Mon Sep 17 00:00:00 2001 From: Peter Babeu Date: Tue, 23 Jan 2018 17:22:20 +0000 Subject: [PATCH] Done. --- index.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 695b9e1..33be0f2 100644 --- a/index.js +++ b/index.js @@ -1 +1,50 @@ -const app = "I don't do much." +const app = "I don't do much."; +var kittens = ['Milo', 'Otis', 'Garfield']; + +function destructivelyAppendKitten(name) { +// appends a kitten to the end of the kittens array + kittens.push(name); + return kittens; +} + +function destructivelyPrependKitten(name) { +// prepends a kitten to the beginning of the kittens array + kittens.unshift(name); + return kittens; +} + +function destructivelyRemoveLastKitten() { +// removes the last kitten from the kittens array + kittens.pop(); + return kittens; +} + +function destructivelyRemoveFirstKitten() { +// removes the First kitten from the kittens array + kittens.shift(); + return kittens; +} + +function appendKitten(name) { +// appends a kitten to the kittens array and returns a new array + var newKittens = [...kittens, name]; + return newKittens; +} + +function prependKitten(name) { +// prepends a kitten to the kittensarray and returns a new array + var newKittens = [name, ...kittens]; + return newKittens; +} + +function removeLastKitten() { +// removes the last kitten in the kittens array and returns a new array + var newKittens = kittens.slice(0, kittens.length-1); + return newKittens; +} + +function removeFirstKitten() { +// removes the first kitten from the kittens array and returns a new array + var newKittens = kittens.slice(1); + return newKittens; +}