From 1afa1b21f4fd3cfef1d4b1aab7ddd9b065631b7b Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Mon, 27 Mar 2023 16:51:29 -0600 Subject: [PATCH 01/19] Add all functions --- mythical-creatures/exercises/dragon.js | 40 +++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/mythical-creatures/exercises/dragon.js b/mythical-creatures/exercises/dragon.js index 0037230de..c7fc9ecfe 100644 --- a/mythical-creatures/exercises/dragon.js +++ b/mythical-creatures/exercises/dragon.js @@ -1,8 +1,40 @@ +function createDragon(name, rider, temperment) { + dragonInfo = { + name, + rider, + temperment, + timesEaten: 0, + hungry: true + }; + return dragonInfo; +}; +function greetRider(dragonInfo) { + return `Hi, ${dragonInfo.rider}!` +} + +function eat(dragonInfo) { + dragonInfo.timesEaten += 1; + if (dragonInfo.timesEaten >= 3) { + dragonInfo.hungry = false + } + return dragonInfo; +} + +function findFireBreathers(allDragons) { + var fireBreathers = []; + for (var i = 0; i < allDragons.length; i++) { + if (dragonInfo.temperment === 'aggressive') { + fireBreathers.push(allDragons[i]); + } + } + console.log(allDragons) + return fireBreathers +} module.exports = { - // createDragon, - // greetRider, - // eat, - // findFireBreathers + createDragon, + greetRider, + eat, + findFireBreathers } \ No newline at end of file From ed397566b8a97cf95044641d44a6167a2cba2c48 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Mon, 27 Mar 2023 16:51:51 -0600 Subject: [PATCH 02/19] Remove all skips --- mythical-creatures/test/dragon-test.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mythical-creatures/test/dragon-test.js b/mythical-creatures/test/dragon-test.js index c5f035bd4..559be6da9 100644 --- a/mythical-creatures/test/dragon-test.js +++ b/mythical-creatures/test/dragon-test.js @@ -3,33 +3,33 @@ var { createDragon, greetRider, eat, findFireBreathers} = require('../exercises/ describe('Dragon', function() { - it.skip('should be able to create a dragon with a name', function() { + it('should be able to create a dragon with a name', function() { var dragon = createDragon('Jeff'); assert.equal(dragon.name, 'Jeff'); }); - it.skip('should be able to have a different name', function() { + it('should be able to have a different name', function() { var dragon = createDragon('Louisa'); assert.equal(dragon.name, 'Louisa'); }); - it.skip('should have a rider', function() { + it('should have a rider', function() { var dragon = createDragon('Saphira', 'Eragon'); assert.equal(dragon.name, 'Saphira'); assert.equal(dragon.rider, 'Eragon'); }); - it.skip('should be able to have a different rider', function() { + it('should be able to have a different rider', function() { var dragon = createDragon('Elliot', 'Pete'); assert.equal(dragon.name, 'Elliot'); assert.equal(dragon.rider, 'Pete'); }); - it.skip('should have a temperment', function() { + it('should have a temperment', function() { var dragon = createDragon('Saphira', 'Eragon', 'gentle'); assert.equal(dragon.name, 'Saphira'); @@ -37,7 +37,7 @@ describe('Dragon', function() { assert.equal(dragon.temperment, 'gentle'); }); - it.skip('should be able to have different temperments', function() { + it('should be able to have different temperments', function() { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); @@ -51,7 +51,7 @@ describe('Dragon', function() { assert.equal(dragon2.temperment, 'gentle'); }); - it.skip('should greet their rider', function() { + it('should greet their rider', function() { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); @@ -62,19 +62,19 @@ describe('Dragon', function() { assert.equal(greeting2, 'Hi, Susie!'); }); - it.skip('should start off having eaten 0 times', function() { + it('should start off having eaten 0 times', function() { var dragon = createDragon('Mushu', 'Mulan', 'aggressive'); assert.equal(dragon.timesEaten, 0); }); - it.skip('should start off being hungry', function() { + it('should start off being hungry', function() { var dragon = createDragon('Mushu', 'Mulan', 'aggressive'); assert.equal(dragon.hungry, true); }); - it.skip('should be full after eating 3 times', function() { + it('should be full after eating 3 times', function() { var dragon = createDragon('Lady Vox', 'Emily', 'gentle'); var fedDragon = eat(dragon); @@ -94,7 +94,7 @@ describe('Dragon', function() { }); //Spicy: - it.skip('should be a fireBreather if aggressive in temperment', function() { + it('should be a fireBreather if aggressive in temperment', function() { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); var dragon3 = createDragon('Mushu', 'Mulan', 'aggressive'); From a39e2c4095c4dc1bf733251da81cf2bf53c70005 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Mon, 27 Mar 2023 16:52:12 -0600 Subject: [PATCH 03/19] Add package-lock.json --- package-lock.json | 178 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index a14533844..a7165814e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,165 +1,214 @@ { "name": "foundations", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "assertion-error": { + "packages": { + "": { + "name": "foundations", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "chai": "^4.2.0", + "mocha": "^5.2.0" + } + }, + "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "browser-stdout": { + "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, - "chai": { + "node_modules/chai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "requires": { + "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.2", "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", "pathval": "^1.1.0", "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" } }, - "check-error": { + "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "engines": { + "node": "*" + } }, - "commander": { + "node_modules/commander": { "version": "2.15.1", "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "debug": { + "node_modules/debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "deep-eql": { + "node_modules/deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "requires": { + "dependencies": { "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" } }, - "diff": { + "node_modules/diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "engines": { + "node": ">=0.3.1" + } }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "engines": { + "node": ">=0.8.0" + } }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "get-func-name": { + "node_modules/get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "engines": { + "node": "*" + } }, - "glob": { + "node_modules/glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "growl": { + "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } }, - "has-flag": { + "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "engines": { + "node": ">=4" + } }, - "he": { + "node_modules/he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "bin": { + "he": "bin/he" + } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "minimatch": { + "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "minimist": { + "node_modules/minimist": { "version": "0.0.8", "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, - "mkdirp": { + "node_modules/mkdirp": { "version": "0.5.1", "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { + "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "dependencies": { "minimist": "0.0.8" + }, + "bin": { + "mkdirp": "bin/cmd.js" } }, - "mocha": { + "node_modules/mocha": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "requires": { + "dependencies": { "browser-stdout": "1.3.1", "commander": "2.15.1", "debug": "3.1.0", @@ -171,45 +220,64 @@ "minimatch": "3.0.4", "mkdirp": "0.5.1", "supports-color": "5.4.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 4.0.0" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { + "dependencies": { "wrappy": "1" } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } }, - "pathval": { + "node_modules/pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "engines": { + "node": "*" + } }, - "supports-color": { + "node_modules/supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "requires": { + "dependencies": { "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "type-detect": { + "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" From 8755ea271f7bf0de4019d7f72e112f0a4d126362 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Tue, 28 Mar 2023 09:37:11 -0600 Subject: [PATCH 04/19] Finalize dragon implementation file --- mythical-creatures/exercises/dragon.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mythical-creatures/exercises/dragon.js b/mythical-creatures/exercises/dragon.js index c7fc9ecfe..294d7d556 100644 --- a/mythical-creatures/exercises/dragon.js +++ b/mythical-creatures/exercises/dragon.js @@ -24,13 +24,12 @@ function eat(dragonInfo) { function findFireBreathers(allDragons) { var fireBreathers = []; for (var i = 0; i < allDragons.length; i++) { - if (dragonInfo.temperment === 'aggressive') { + if (allDragons[i].temperment === 'aggressive') { fireBreathers.push(allDragons[i]); } } - console.log(allDragons) - return fireBreathers -} + return fireBreathers; +}; module.exports = { createDragon, From b9be1279add550222bb1dfd26329535ed95e0db1 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Tue, 28 Mar 2023 17:48:00 -0600 Subject: [PATCH 05/19] Complete vampire implementation file --- mythical-creatures/exercises/vampire.js | 54 ++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/mythical-creatures/exercises/vampire.js b/mythical-creatures/exercises/vampire.js index 930b9e5cc..2b16b1ca1 100644 --- a/mythical-creatures/exercises/vampire.js +++ b/mythical-creatures/exercises/vampire.js @@ -1,9 +1,53 @@ +function createVampire(name, pet) { + var vampire = { + name, + pet: pet || 'bat', + thirsty: true, + ouncesDrank: 0 + } + return vampire; +}; +function encounterDeliciousVictim(vampire) { + if (vampire.thirsty === true){ + return `I WANT TO SUCK YOUR BLOOD!` + } else { + return `No thanks, I am too full.` + } +} + +function drink(vampire) { + if (vampire.thirsty === true) { + vampire.ouncesDrank += 10; + } + if (vampire.ouncesDrank === 50) { + vampire.thirsty = false; + } + return vampire; +}; + +function inquirePlace(locations, cityName) { + if (locations.includes(cityName)) { + return `Yes, I have spent some time in ${cityName}.` + } else { + return `No, I have never been to ${cityName}.` + } + } + +function findBatLovers(vampires) { + var batLovers = []; + for (var i = 0; i < vampires.length; i++) { + if (vampires[i].pet === 'bat') { + batLovers.push(vampires[i].name); + } + } + return batLovers; +}; module.exports = { - // createVampire, - // drink, - // findBatLovers, - // encounterDeliciousVictim, - // inquirePlace + createVampire, + drink, + findBatLovers, + encounterDeliciousVictim, + inquirePlace } \ No newline at end of file From e3e58d9afadc682c2af9516117c3fd41fc7480b5 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Tue, 28 Mar 2023 17:48:17 -0600 Subject: [PATCH 06/19] Remove all the skips --- mythical-creatures/test/vampire-test.js | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mythical-creatures/test/vampire-test.js b/mythical-creatures/test/vampire-test.js index b63b1565e..712372a67 100644 --- a/mythical-creatures/test/vampire-test.js +++ b/mythical-creatures/test/vampire-test.js @@ -3,20 +3,20 @@ var {createVampire, drink, findBatLovers, encounterDeliciousVictim, inquirePlace describe('Vampire', function() { - it.skip('should create a vampire', function() { + it('should create a vampire', function() { var vampire = createVampire('Jhun'); assert.equal(vampire.name, 'Jhun'); }); - it.skip('should have a pet bat as a default', function() { + it('should have a pet bat as a default', function() { var vampire = createVampire('Brittany'); assert.equal(vampire.name, 'Brittany'); assert.equal(vampire.pet, 'bat'); }); - it.skip('should be able to take an argument for pet', function() { + it('should be able to take an argument for pet', function() { var vampire = createVampire('Jeff', 'fox'); var vampira = createVampire('Esme', 'armadillo'); @@ -24,13 +24,13 @@ describe('Vampire', function() { assert.equal(vampira.pet, 'armadillo'); }); - it.skip('should be thirsty', function() { + it('should be thirsty', function() { var vampire = createVampire('Andy'); assert.equal(vampire.thirsty, true); }); - it.skip('should should at victim when thirsty', function() { + it('should should at victim when thirsty', function() { var vampire = createVampire('Andy'); var expectedResponse = 'I WANT TO SUCK YOUR BLOOD!' @@ -39,13 +39,13 @@ describe('Vampire', function() { assert.equal(shout, expectedResponse); }); - it.skip('should be start with no ounces of blood drank', function() { + it('should be start with no ounces of blood drank', function() { var vampire = createVampire('Bobby'); assert.equal(vampire.ouncesDrank, 0); }); - it.skip('should drink 10 ounces of blood at a time', function() { + it('should drink 10 ounces of blood at a time', function() { var vampire = createVampire('Margot'); var drankOnceVamp = drink(vampire); @@ -61,7 +61,7 @@ describe('Vampire', function() { assert.equal(drankThriceVamp.ouncesDrank, 30); }); - it.skip('should no longer be thirsty after drinking 50 ounces', function() { + it('should no longer be thirsty after drinking 50 ounces', function() { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -74,7 +74,7 @@ describe('Vampire', function() { assert.equal(drank5xsVamp.thirsty, false); }); - it.skip('should not drink more ounces when not thirsty', function() { + it('should not drink more ounces when not thirsty', function() { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -91,7 +91,7 @@ describe('Vampire', function() { assert.equal(notDrinking6xsVamp.ouncesDrank, 50); }); - it.skip('should refuse blood from victim when not thirsty', function() { + it('should refuse blood from victim when not thirsty', function() { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -108,7 +108,7 @@ describe('Vampire', function() { assert.equal(response, `No thanks, I am too full.`); }); - it.skip('should say if its been to a location', function() { + it('should say if its been to a location', function() { var locations = ['Transylvania', 'Washington', 'New Orleans', 'Mystic Falls']; var response = inquirePlace(locations, 'New Orleans'); @@ -117,7 +117,7 @@ describe('Vampire', function() { assert.deepEqual(response, expectedResponse); }); - it.skip('should say if its not been to a location', function() { + it('should say if its not been to a location', function() { var locations = ['Transylvania', 'Washington', 'New Orleans', 'Mystic Falls']; var response = inquirePlace(locations, 'Idaho'); @@ -127,7 +127,7 @@ describe('Vampire', function() { }); //Spicy - it.skip('should be able to find the vampires with bats', function() { + it('should be able to find the vampires with bats', function() { var javi = createVampire('Javi'); var brittany = createVampire('Brittany'); var jeff = createVampire('Jeff', 'fox'); From cb1ed07918de993461a01b42cc9a51a813904e33 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Tue, 28 Mar 2023 18:23:14 -0600 Subject: [PATCH 07/19] Added 4/5 functions still work in progress --- mythical-creatures/exercises/hobbit.js | 40 +++++++++++++++++++++++--- mythical-creatures/test/hobbit-test.js | 20 ++++++------- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/mythical-creatures/exercises/hobbit.js b/mythical-creatures/exercises/hobbit.js index 6d9602430..ec41f2b58 100644 --- a/mythical-creatures/exercises/hobbit.js +++ b/mythical-creatures/exercises/hobbit.js @@ -1,9 +1,41 @@ +function createHobbit(name, age) { + var hobbit = { + name: name || 'unknown', + age: age || 0, + isAdult: false, + isOld: false, + acquaintances: [] + } + return hobbit; +}; +function celebrateBirthday(hobbit) { + hobbit.age += 1; + if (hobbit.age > 32) { + hobbit.isAdult = true; + } + if (hobbit.age >= 101) { + hobbit.isOld = true; + } + return hobbit; +}; + +function getRing(hobbit) { + if (hobbit.name === 'Frodo') { + return 'Here is the ring!'; + } else { + return 'You can\'t have it!'; + } +}; + +function meetPeople(hobbit, people) { + +} module.exports = { - // createHobbit, - // celebrateBirthday, - // getRing, - // meetPeople, + createHobbit, + celebrateBirthday, + getRing, + meetPeople, // findFriends } \ No newline at end of file diff --git a/mythical-creatures/test/hobbit-test.js b/mythical-creatures/test/hobbit-test.js index fa53686c0..d9c07e64a 100644 --- a/mythical-creatures/test/hobbit-test.js +++ b/mythical-creatures/test/hobbit-test.js @@ -3,7 +3,7 @@ var {createHobbit, celebrateBirthday, getRing, meetPeople, findFriends} = requir describe('Hobbit', function() { - it.skip('should make a hobbit with a name and age', function() { + it('should make a hobbit with a name and age', function() { var bilbo = createHobbit('Bilbo', 0); var mark = createHobbit('Mark', 5); @@ -14,20 +14,20 @@ describe('Hobbit', function() { assert.equal(mark.age, 5); }); - it.skip('should start out 0 years old if not specified', function() { + it('should start out 0 years old if not specified', function() { var bilbo = createHobbit('Bilbo'); assert.equal(bilbo.age, 0); }); - it.skip('should return an object with defaults if nothing passed', function() { + it('should return an object with defaults if nothing passed', function() { var hobbit = createHobbit(); assert.equal(hobbit.name, 'unknown'); assert.equal(hobbit.age, 0); }); - it.skip('should gain 1 year after every birthday', function() { + it('should gain 1 year after every birthday', function() { var hobbit = createHobbit('Meriadoc'); var olderHobbit = celebrateBirthday(hobbit); @@ -37,7 +37,7 @@ describe('Hobbit', function() { assert.equal(evenOlderStillHobbit.age, 3); }); - it.skip('should be considered a child at the age of 32', function() { + it('should be considered a child at the age of 32', function() { var taylor = createHobbit('Taylor', 31); assert.equal(taylor.age, 31); @@ -49,7 +49,7 @@ describe('Hobbit', function() { assert.equal(olderTaylor.isAdult, false); }); - it.skip('should be considered an adult at 33', function() { + it('should be considered an adult at 33', function() { var ryan = createHobbit('Ryan', 32); var olderRyan = celebrateBirthday(ryan); @@ -58,7 +58,7 @@ describe('Hobbit', function() { assert.equal(olderRyan.isAdult, true); }); - it.skip('should be considered old at the age of 101', function() { + it('should be considered old at the age of 101', function() { var samwise = createHobbit('Samwise', 99); assert.equal(samwise.age, 99) @@ -75,7 +75,7 @@ describe('Hobbit', function() { assert.equal(hundredAndOneSamwise.isOld, true) }); - it.skip('should be able to get the ring if its name is Frodo', function() { + it('should be able to get the ring if its name is Frodo', function() { var hobbit1 = createHobbit('Frodo'); var hobbit2 = createHobbit('Samwise'); @@ -83,7 +83,7 @@ describe('Hobbit', function() { assert.equal(getRing(hobbit2), 'You can\'t have it!'); }); - it.skip('should start with no acquaintances', function() { + it('should start with no acquaintances', function() { var bilbo = createHobbit('Bilbo'); assert.equal(bilbo.name, 'Bilbo'); @@ -92,7 +92,7 @@ describe('Hobbit', function() { }); //Spicy - it.skip('should be able to meet people', function() { + it('should be able to meet people', function() { var people = [ {name: 'Nick', relationship: 'friend'} ]; var bilbo = createHobbit('Bilbo'); From bf90031359e5c03e07e6cec62be75666d076ac2c Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Wed, 29 Mar 2023 16:15:01 -0600 Subject: [PATCH 08/19] Complete hobbit implementation file --- mythical-creatures/exercises/hobbit.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mythical-creatures/exercises/hobbit.js b/mythical-creatures/exercises/hobbit.js index ec41f2b58..dc4ea3f98 100644 --- a/mythical-creatures/exercises/hobbit.js +++ b/mythical-creatures/exercises/hobbit.js @@ -29,13 +29,26 @@ function getRing(hobbit) { }; function meetPeople(hobbit, people) { - -} + for (var i = 0; i < people.length; i++) { + hobbit.acquaintances.push(people[i]); + } + return hobbit; +}; + +function findFriends(hobbit) { + var friends = []; + for (var i = 0; i < hobbit.acquaintances.length; i++) { + if (hobbit.acquaintances[i].relationship === 'friend') { + friends.push(hobbit.acquaintances[i].name) + } + } + return friends; +}; module.exports = { createHobbit, celebrateBirthday, getRing, meetPeople, - // findFriends + findFriends } \ No newline at end of file From 979bb891824234214858308297721505419b42e0 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Wed, 29 Mar 2023 16:18:43 -0600 Subject: [PATCH 09/19] Remove all skips --- mythical-creatures/test/hobbit-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mythical-creatures/test/hobbit-test.js b/mythical-creatures/test/hobbit-test.js index d9c07e64a..bd3136ce7 100644 --- a/mythical-creatures/test/hobbit-test.js +++ b/mythical-creatures/test/hobbit-test.js @@ -104,7 +104,7 @@ describe('Hobbit', function() { assert.equal(socialBilbo.acquaintances[0].relationship, 'friend'); }); - it.skip('should be able to meet several people at once', function() { + it('should be able to meet several people at once', function() { var people = [ {name: 'Nick', relationship: 'friend'}, {name: 'Ben', relationship: 'enemy'} ]; var bilbo = createHobbit('Bilbo'); @@ -117,7 +117,7 @@ describe('Hobbit', function() { assert.deepEqual(socialBilbo.acquaintances, people); }); - it.skip('should be able to meet people on multiple occasions', function() { + it('should be able to meet people on multiple occasions', function() { var nick = {name: 'Nick', relationship: 'friend'}; var ben = {name: 'Ben', relationship: 'enemy'}; var people = [ nick, ben ]; @@ -138,7 +138,7 @@ describe('Hobbit', function() { assert.deepEqual(moreSocialBilbo.acquaintances, [nick, ben, trisha, dustin]); }); - it.skip('should be able to identify which acquaintances are friends ', function() { + it('should be able to identify which acquaintances are friends ', function() { var foster = {name: 'Foster', relationship: 'friend'}; var allie = {name: 'Allie', relationship: 'enemy'}; var garrett = {name: 'Garrett', relationship: 'enemy'}; From 52322b80d4f94617dced5fa4a6f284a90920b604 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Mon, 3 Apr 2023 12:56:01 -0600 Subject: [PATCH 10/19] Add all the functions, still solving the last one --- airport/airport.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/airport/airport.js b/airport/airport.js index 8966a87f7..55b4c390f 100644 --- a/airport/airport.js +++ b/airport/airport.js @@ -1,9 +1,33 @@ +function createAirport(name, airlines, availableGates) { + var airport = { + name, + airlines, + availableGates, + } + return airport; +}; + +function welcomeGuests(airport) { + return `Welcome to ${airport.name}!` +} + +function landPlanes(airport, planesLandedCt) { + airport.availableGates -= planesLandedCt; + if (airport.availableGates > 0) { + return `Success! Current availability is ${airport.availableGates}.` + } else if (airport.availableGates < 0){ + airport.availableGates = 0; + return `Oh no! Not enough gates available. Current overflow is 1.` + } +} +function checkAirlineLocations(airport, airline) { +} module.exports = { - // createAirport, - // welcomeGuests, - // landPlanes, - // checkAirlineLocations + createAirport, + welcomeGuests, + landPlanes, + checkAirlineLocations }; From 2520505bcc4b17779474e51c3a97fb16bb8c4f56 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Tue, 4 Apr 2023 16:32:24 -0600 Subject: [PATCH 11/19] Remove all skips --- airport/airport-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/airport/airport-test.js b/airport/airport-test.js index 246224309..cf3a3ecee 100644 --- a/airport/airport-test.js +++ b/airport/airport-test.js @@ -2,7 +2,7 @@ var assert = require('chai').assert; var { createAirport, welcomeGuests, landPlanes, checkAirlineLocations } = require('./airport'); describe('Airport', function() { - it.skip('should create an airport', function() { + it('should create an airport', function() { var airport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144); assert.equal(airport.name, 'Denver International Airport'); @@ -10,7 +10,7 @@ describe('Airport', function() { assert.equal(airport.airlines[0], 'United'); }); - it.skip('should welcome people to the airport', function() { + it('should welcome people to the airport', function() { var denverAirport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144); var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); @@ -22,7 +22,7 @@ describe('Airport', function() { assert.equal(sanDiegoWelcome, 'Welcome to San Diego International Airport!'); }); - it.skip('should keep track of open gates', function() { + it('should keep track of open gates', function() { var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12); var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); @@ -33,7 +33,7 @@ describe('Airport', function() { assert.equal(sanDiegoAirport.availableGates, 46); }); - it.skip('should not be able to occupy more gates than available', function() { + it('should not be able to occupy more gates than available', function() { var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24); var occupiedGates1 = landPlanes(columbusAiport, 22); @@ -47,7 +47,7 @@ describe('Airport', function() { assert.equal(occupiedGates2, 'Oh no! Not enough gates available. Current overflow is 1.') }); - it.skip('should be able to tell you where an airline flies to', function() { + it('should be able to tell you where an airline flies to', function() { var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24); var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12); var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); From 03bc529ec634c2125fcdadf7b678aa97ed495217 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Wed, 5 Apr 2023 20:31:28 -0600 Subject: [PATCH 12/19] Airport Schmairport --- airport/airport.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airport/airport.js b/airport/airport.js index 55b4c390f..222c74655 100644 --- a/airport/airport.js +++ b/airport/airport.js @@ -21,8 +21,8 @@ function landPlanes(airport, planesLandedCt) { } } -function checkAirlineLocations(airport, airline) { - +function checkAirlineLocations(allAirport, airline) { + // } module.exports = { From 7671267a56b6a708e1dfe452472bf3af58db33f9 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 6 Apr 2023 12:42:44 -0600 Subject: [PATCH 13/19] Complete Airport implementation file --- airport/airport.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/airport/airport.js b/airport/airport.js index 222c74655..5341835e2 100644 --- a/airport/airport.js +++ b/airport/airport.js @@ -9,7 +9,7 @@ function createAirport(name, airlines, availableGates) { function welcomeGuests(airport) { return `Welcome to ${airport.name}!` -} +}; function landPlanes(airport, planesLandedCt) { airport.availableGates -= planesLandedCt; @@ -19,11 +19,17 @@ function landPlanes(airport, planesLandedCt) { airport.availableGates = 0; return `Oh no! Not enough gates available. Current overflow is 1.` } -} +}; -function checkAirlineLocations(allAirport, airline) { - // -} +function checkAirlineLocations(allAirports, airline) { + var flightLocations = []; + for (var i = 0; i < allAirports.length; i++) { + if (allAirports[i].airlines.includes(airline)) { + flightLocations.push(allAirports[i].name) + } + } + return flightLocations; +}; module.exports = { createAirport, From 954435ef6d8cd1e89e15d2f1aea36bb144429394 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 6 Apr 2023 13:02:50 -0600 Subject: [PATCH 14/19] Add createBarber and giveCompliment function --- barber-shop/barber.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/barber-shop/barber.js b/barber-shop/barber.js index 16d2dd549..885066ff7 100644 --- a/barber-shop/barber.js +++ b/barber-shop/barber.js @@ -1,3 +1,17 @@ +function createBarber(name, earnings, haircuts) { + var barber = { + name, + earnings: earnings || 0, + haircuts: haircuts || [], + } + return barber; +} +function giveCompliment(cutType) { + +} -module.exports = { }; \ No newline at end of file +module.exports = { + createBarber, + giveCompliment +}; \ No newline at end of file From 4ae1dc4d10e4c7e382b1843014fd0ac2936a373d Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 6 Apr 2023 13:03:07 -0600 Subject: [PATCH 15/19] Remove first four skips --- barber-shop/barber-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barber-shop/barber-test.js b/barber-shop/barber-test.js index 9f589ff64..3e00a586c 100644 --- a/barber-shop/barber-test.js +++ b/barber-shop/barber-test.js @@ -2,13 +2,13 @@ var assert = require('chai').assert; var { createBarber, giveCompliment, cutHair, listStyles } = require('./barber'); describe('Barber', function() { - it.skip('should create a barber with a name', function() { + it('should create a barber with a name', function() { var sam = createBarber('Sam'); assert.equal(sam.name, 'Sam'); }) - it.skip('should be able to have earnings and known haircuts', function() { + it('should be able to have earnings and known haircuts', function() { var cut1 = { style: 'mohawk', hairLength: 'short', price: 11.00 }; var cut2 = { style: 'side part', hairLength: 'medium', price: 12.00 }; @@ -19,7 +19,7 @@ describe('Barber', function() { assert.deepEqual(erin.haircuts, [cut1, cut2]); }); - it.skip('should default to no earnings and no haircuts if none provided', function() { + it('should default to no earnings and no haircuts if none provided', function() { var buzzCut = { style: 'buzz', hairLength: 'short', price: 8.00 }; var nick = createBarber('Nick', 8.00, [buzzCut]); @@ -32,7 +32,7 @@ describe('Barber', function() { assert.deepEqual(pam.haircuts, []); }); - it.skip('should be able to offer a compliment', function() { + it('should be able to offer a compliment', function() { var mohawkCut = { style: 'mohawk', hairLength: 'short', price: 11.00 }; var buzzCut = { style: 'buzz', hairLength: 'short', price: 8.00 }; From ca8b078d360921fc779ec9a175e3afcb2f0bcd62 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 6 Apr 2023 19:02:30 -0600 Subject: [PATCH 16/19] AHHhhhhh --- barber-shop/barber-test.js | 2 +- barber-shop/barber.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/barber-shop/barber-test.js b/barber-shop/barber-test.js index 3e00a586c..76059f5a1 100644 --- a/barber-shop/barber-test.js +++ b/barber-shop/barber-test.js @@ -45,7 +45,7 @@ describe('Barber', function() { assert.equal(buzzCompliment, 'This buzz looks great!'); }); - it.skip('should be able to cut hair', function() { + it('should be able to cut hair', function() { var matt = createBarber('Matt'); var mohawkCut = { style: 'mohawk', hairLength: 'short', price: 11.00 }; diff --git a/barber-shop/barber.js b/barber-shop/barber.js index 885066ff7..874ed43f3 100644 --- a/barber-shop/barber.js +++ b/barber-shop/barber.js @@ -7,11 +7,17 @@ function createBarber(name, earnings, haircuts) { return barber; } -function giveCompliment(cutType) { +function giveCompliment(hairStyle) { + return `This ${hairStyle.style} looks great!`; +} + +function cutHair(customer, hairStyle) { + var haircuts = []; } module.exports = { createBarber, - giveCompliment + giveCompliment, + cutHair }; \ No newline at end of file From 8822d9f5b0bbfa918baf461df4d7aacdb10e81ce Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 13 Apr 2023 13:05:53 -0600 Subject: [PATCH 17/19] change perameter name from customer to barber --- barber-shop/barber.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barber-shop/barber.js b/barber-shop/barber.js index 874ed43f3..d00e29da9 100644 --- a/barber-shop/barber.js +++ b/barber-shop/barber.js @@ -11,7 +11,7 @@ function giveCompliment(hairStyle) { return `This ${hairStyle.style} looks great!`; } -function cutHair(customer, hairStyle) { +function cutHair(barber, hairStyle) { var haircuts = []; } From 311f333cae65b45b4ebaabaf401c7af311d1cc77 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 13 Apr 2023 13:21:01 -0600 Subject: [PATCH 18/19] Complete and solve birthday test --- birthdays/birthdays-test.js | 6 +++--- birthdays/birthdays.js | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/birthdays/birthdays-test.js b/birthdays/birthdays-test.js index a2573d210..5b082c279 100644 --- a/birthdays/birthdays-test.js +++ b/birthdays/birthdays-test.js @@ -2,7 +2,7 @@ var assert = require('chai').assert; var { createBirthday, celebrateBirthday, countBirthdays } = require('./birthdays'); describe('Birthdays', function() { - it.skip('should create birthdays', function() { + it('should create birthdays', function() { var leahBirthday = createBirthday('Leah', 2, 10); var christyBirthday = createBirthday('Christy', 3, 8); @@ -15,7 +15,7 @@ describe('Birthdays', function() { assert.deepEqual(christyBirthday.day, 8); }); - it.skip('should celebrate birthdays', function() { + it('should celebrate birthdays', function() { var alexBirthday = createBirthday('Alex', 5, 19); var celebrateAlex = celebrateBirthday(alexBirthday); @@ -29,7 +29,7 @@ describe('Birthdays', function() { assert.equal(celebrateHeather, 'Today is 6/29! Happy birthday, Heather!'); }) - it.skip('should count how many birthdays are in a given month', function() { + it('should count how many birthdays are in a given month', function() { var leahBirthday = createBirthday('Leah', 2, 10); var christyBirthday = createBirthday('Christy', 3, 8); var alexBirthday = createBirthday('Alex', 5, 19); diff --git a/birthdays/birthdays.js b/birthdays/birthdays.js index 16d2dd549..59755c60a 100644 --- a/birthdays/birthdays.js +++ b/birthdays/birthdays.js @@ -1,3 +1,27 @@ +function createBirthday(name, month, day) { + var birthdayInfo = { + name, + month, + day + } + return birthdayInfo; +}; +function celebrateBirthday(birthdayInfo) { + return `Today is ${birthdayInfo.month}/${birthdayInfo.day}! Happy birthday, ${birthdayInfo.name}!` +}; -module.exports = { }; \ No newline at end of file +function countBirthdays(birthdaysArray, month) { + var counter = 0; + for (var i = 0; i < birthdaysArray.length; i++) { + if (birthdaysArray[i].month === month) + counter += 1; + } + return counter; +}; + +module.exports = { + createBirthday, + celebrateBirthday, + countBirthdays + }; \ No newline at end of file From a87c1da6a1f3276983f776d43057034e4ed7f1c5 Mon Sep 17 00:00:00 2001 From: Denzel Turambi Date: Thu, 13 Apr 2023 13:35:38 -0600 Subject: [PATCH 19/19] Solve and complete calender test --- calendar/calendar-test.js | 8 ++++---- calendar/calendar.js | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/calendar/calendar-test.js b/calendar/calendar-test.js index b6f554a08..1072025ab 100644 --- a/calendar/calendar-test.js +++ b/calendar/calendar-test.js @@ -3,7 +3,7 @@ var { createEvent, createCalendar, reportMonthlyEvents } = require('./calendar') describe('Calendar', function () { - it.skip('should create an event', function () { + it('should create an event', function () { var event = createEvent("Go to the Park", "August", 25); assert.equal(event.title, "Go to the Park"); @@ -18,7 +18,7 @@ describe('Calendar', function () { assert.equal(event2.day, 1); }); - it.skip('should return an error if an invalid day is passed in', function () { + it('should return an error if an invalid day is passed in', function () { var event1 = createEvent("Go to the Park", "August", 35); assert.equal(event1, "Error: 35 is not a valid day"); @@ -26,7 +26,7 @@ describe('Calendar', function () { assert.equal(event2, "Error: 0 is not a valid day"); }); - it.skip('should create a calendar with events', function () { + it('should create a calendar with events', function () { var event1 = createEvent("Go to the Park", "August", 25); var event2 = createEvent("Dinner with Lucy", "September", 10); var events = [event1, event2]; @@ -43,7 +43,7 @@ describe('Calendar', function () { assert.deepEqual(calendar2.events, [event1, event2]); }); - it.skip('should gather events from the same month', function () { + it('should gather events from the same month', function () { var event1 = createEvent("Go to the Park", "August", 25); var event2 = createEvent("Dinner with Lucy", "July", 10); var event3 = createEvent("Order More Batteries", "July", 2); diff --git a/calendar/calendar.js b/calendar/calendar.js index 16d2dd549..b85b16a03 100644 --- a/calendar/calendar.js +++ b/calendar/calendar.js @@ -1,3 +1,36 @@ +function createEvent(title, month, day) { + var calenderEvent = { + title, + month, + day + } + if (calenderEvent.day > 31 || calenderEvent.day <= 0){ + return `Error: ${calenderEvent.day} is not a valid day` + } + return calenderEvent; +} +function createCalendar(owner, events) { + var calender = { + owner, + events + } + return calender; +} -module.exports = { }; \ No newline at end of file +function reportMonthlyEvents(calender, month) { + console.log(calender); + var monthlyEvents = []; + for (var i = 0; i < calender.events.length; i++) { + if (calender.events[i].month === month) { + monthlyEvents.push(calender.events[i]); + } + } + return monthlyEvents; +} + +module.exports = { + createEvent, + createCalendar, + reportMonthlyEvents + }; \ No newline at end of file