diff --git a/README.md b/README.md index cea8ca45e..bb2ed6b9b 100644 --- a/README.md +++ b/README.md @@ -42,24 +42,24 @@ We find that when students complete the same test suite over and over, memorizat Completing all of these test suites is not necessary, but you should be working on this repo regularly. We see that students are the most successful when they establish a routine for working through these test suites. For example, you might work on them for 45 minutes every morning before class. Find a routine that works best for you and plan ahead so you remain on track to complete the majority of the tests. ### Test Suites -- [ ] ๐Ÿงš โ€[Mythical Creatures](./mythical-creatures) -- [ ] โœˆ๏ธ [Airport](./airport) -- [ ] ๐ŸŽง [DJ](./dj) -- [ ] ๐Ÿ” [Favorite Foods](./favorite-foods) -- [ ] ๐ŸŽฎ [Video Games](./video-games/) -- [ ] ๐ŸŽ‚ [Birthdays](./birthdays) -- [ ] ๐Ÿ—“ [Calendar](./calendar/) +- [x] ๐Ÿงš โ€[Mythical Creatures](./mythical-creatures) - DONE +- [x] ๐ŸŽ‚ [Birthdays](./birthdays) - DONE +- [x] ๐Ÿ—“ [Calendar](./calendar/) - DONE +- [x] ๐ŸŽฎ [Video Games](./video-games/) - DONE +- [x] ๐ŸŒฎ [Taco Stand](./tacoStand/) - DONE +- [x] ๐Ÿฅ— [Meal Planning](./meal-planning/) - DONE +- [x] ๐Ÿ›— [Elevator](./elevator/) - DONE +- [x] ๐ŸŽต [Spotify](./spotify/) - DONE +- [x] ๐Ÿง–โ€โ™€๏ธ [Spa](./spa/) - DONE +- [ ] โœ‚๏ธ [Barber Shop](./barber-shop/) - [ ] ๐Ÿ’ต [Vending Machine](./vending-machine/) -- [ ] ๐Ÿ›— [Elevator](./elevator/) +- [ ] ๐Ÿ“ผ [VHS](./vhs/) +- [ ] ๐ŸŽง [DJ](./dj) +- [x] ๐Ÿ” [Favorite Foods](./favorite-foods) - DONE - [ ] ๐Ÿ“š [Library](./library) -- [ ] ๐ŸŒฎ [Taco Stand](./tacoStand/) -- [ ] ๐Ÿงถ [Crafting](./crafting/) -- [ ] โœ‚๏ธ [Barber Shop](./barber-shop/) -- [ ] ๐Ÿฅ— [Meal Planning](./meal-planning/) +- [x] ๐Ÿงถ [Crafting](./crafting/) - DONE - [ ] ๐Ÿœ [Restaurant](./restaurant/) -- [ ] ๐Ÿง–โ€โ™€๏ธ [Spa](./spa/) -- [ ] ๐ŸŽต [Spotify](./spotify/) -- [ ] ๐Ÿ“ผ [VHS](./vhs/) +- [x] โœˆ๏ธ [Airport](./airport) - DONE - [x] Want to track your progress? First, make sure you're on a forked version of this repo. Then, you can edit the README and change `[ ]` to `[x]` on the suites you've completed! diff --git a/airport/airport-test.js b/airport/airport-test.js index 5c1e20091..94826e1b3 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(sanDiegoGates.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 updatedAirportGates = landPlanes(columbusAiport, 22); @@ -47,7 +47,7 @@ describe('Airport', function() { assert.equal(updatedAirportGates2.message, '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); diff --git a/airport/airport.js b/airport/airport.js index 8966a87f7..055d63c86 100644 --- a/airport/airport.js +++ b/airport/airport.js @@ -1,9 +1,43 @@ +function createAirport(name1, airlines1, availableGates1) { + var airport1 = { + name: name1, + airlines: airlines1, + availableGates: availableGates1 + } + return airport1 +}; +function welcomeGuests(airport) { + return `Welcome to ${airport.name}!` +}; +function landPlanes(airport, usedGates) { + var overflow = usedGates - airport.availableGates + airport.availableGates -= usedGates + if(airport.availableGates < 0) { + airport.message = `Oh no! Not enough gates available. Current overflow is ${overflow}.` + airport.availableGates = 0 + } else { + airport.message = `Success! Current availability is ${airport.availableGates}.` + } + return airport +}; + +function checkAirlineLocations(airports, airline) { + var airportNames = []; + for(var i = 0; i < airports.length; i++) { + for (var z = 0; z < airports[i].airlines.length; z++) { + if(airports[i].airlines[z] === airline) { + airportNames.push(airports[i].name) + } + } + } + return airportNames +}; module.exports = { - // createAirport, - // welcomeGuests, - // landPlanes, - // checkAirlineLocations + createAirport, + welcomeGuests, + landPlanes, + checkAirlineLocations }; diff --git a/birthdays/birthdays-test.js b/birthdays/birthdays-test.js index a2573d210..5a1fa0518 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,13 +29,13 @@ 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); var noahBirthday = createBirthday('Noah', 2, 16); var birthdays = [leahBirthday, christyBirthday, alexBirthday, noahBirthday]; - +console.log('birthdays:', birthdays) var febCount = countBirthdays(birthdays, 2); var mayCount = countBirthdays(birthdays, 5); var decCount = countBirthdays(birthdays, 12); diff --git a/birthdays/birthdays.js b/birthdays/birthdays.js index 16d2dd549..2c796d1d9 100644 --- a/birthdays/birthdays.js +++ b/birthdays/birthdays.js @@ -1,3 +1,28 @@ +function createBirthday(name, month, day) { + var birthday = { + name: name, + month: month, + day: day + } + return birthday; +}; +function celebrateBirthday(birthday) { + return `Today is ${birthday.month}/${birthday.day}! Happy birthday, ${birthday.name}!`; +}; -module.exports = { }; \ No newline at end of file +function countBirthdays(people, month) { + var birthdayCount = 0; + for(var i = 0; i < people.length; i++) { + if(people[i].month === month) { + birthdayCount ++ + } + } + return birthdayCount; +}; + +module.exports = { + createBirthday, + celebrateBirthday, + countBirthdays +}; \ No newline at end of file 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..a3711665a 100644 --- a/calendar/calendar.js +++ b/calendar/calendar.js @@ -1,3 +1,35 @@ +function createEvent(title1, month1, day1) { + var agenda = { + title: title1, + month: month1, + day: day1 + } + if(agenda.day < 1 || agenda.day > 31){ + return `Error: ${agenda.day} is not a valid day` + } + return agenda +}; +function createCalendar(name, events1) { + var calendar1 = { + owner: name, + events: events1 + } + return calendar1 +}; -module.exports = { }; \ No newline at end of file +function reportMonthlyEvents(calendar1, month) { + var monthlyEvents1 = []; + for(var i = 0; i < calendar1.events.length; i++) { + if (calendar1.events[i].month === month) { + monthlyEvents1.push(calendar1.events[i]) + } + } + return monthlyEvents1 +}; + +module.exports = { + createEvent, + createCalendar, + reportMonthlyEvents +}; \ No newline at end of file diff --git a/crafting/crafts-test.js b/crafting/crafts-test.js index c97ab2786..936c953d7 100644 --- a/crafting/crafts-test.js +++ b/crafting/crafts-test.js @@ -4,7 +4,7 @@ var { createMaterial, calculateMaterialCost, createSupplyCloset, addSupply, crea describe('Crafting', function() { describe('Material', function() { - it.skip('should create a new material', function() { + it('should create a new material', function() { var yarn = createMaterial('yarn', 'skein', 6.99); assert.equal(yarn.name, 'yarn'); @@ -12,7 +12,7 @@ describe('Crafting', function() { assert.equal(yarn.costPerUnit, 6.99); }); - it.skip('should calculate cost of material', function() { + it('should calculate cost of material', function() { var fabric = createMaterial('fabric', 'yard', 12.50); var fabricCost = calculateMaterialCost(fabric, 4); @@ -28,7 +28,7 @@ describe('Crafting', function() { }); describe('Supply Closet', function() { - it.skip('should create a supply closet', function() { + it('should create a supply closet', function() { var fabric = createMaterial('fabric', 'yard', 12.50); var paint = createMaterial('paint', 'pint', 3.95); var yarn = createMaterial('yarn', 'skein', 6.99); @@ -38,13 +38,13 @@ describe('Crafting', function() { assert.deepEqual(myCloset, { supplies: ['fabric', 'paint', 'yarn'] }); }); - it.skip('should be able to start empty', function() { + it('should be able to start empty', function() { var myCloset = createSupplyCloset(); assert.deepEqual(myCloset, { supplies: [] }); }); - it.skip('should be able to add new supplies to the supply closet', function() { + it('should be able to add new supplies to the supply closet', function() { var glitter = createMaterial('glitter', 'ounce', .99); var myCloset = createSupplyCloset([glitter]); @@ -56,7 +56,7 @@ describe('Crafting', function() { assert.deepEqual(updatedCloset, ['glitter', 'thread']); }); - it.skip('should not allow you to add the same supply again', function() { + it('should not allow you to add the same supply again', function() { var fabric = createMaterial('fabric', 'yard', 12.50); var paint = createMaterial('paint', 'pint', 3.95); @@ -67,7 +67,7 @@ describe('Crafting', function() { }); describe('Project', function() { - it.skip('should create a new craft project', function() { + it('should create a new craft project', function() { var thread = createMaterial('thread', 'bobbin', 3.67); var fabric = createMaterial('aida fabric', 'yard', 15.50); var materials = [thread, fabric]; @@ -78,14 +78,14 @@ describe('Crafting', function() { assert.equal(crossStitchProject.status, 'in progress'); }); - it.skip('should have a status of not started if not specified', function() { + it('should have a status of not started if not specified', function() { var string = createMaterial('warp string', 'yard', .49); var yarn = createMaterial('yarn', 'skein', 7.85); assert.equal(createNewProject([string, yarn]).status, 'not started'); }); - it.skip('should be able to see if you have the necessary supplies to start a project', function() { + it('should be able to see if you have the necessary supplies to start a project', function() { var paper = createMaterial('paper', 'ream', 13.99); var paint = createMaterial('paint', 'bottle', '4.50'); @@ -100,7 +100,7 @@ describe('Crafting', function() { assert.equal(check, 'Yay! You can start this project!'); }); - it.skip('should be able to see if you have the necessary supplies to start a project', function() { + it('should be able to see if you have the necessary supplies to start a project', function() { var string = createMaterial('warp string', 'yard', .49); var yarn = createMaterial('yarn', 'skein', 7.85); diff --git a/crafting/crafts.js b/crafting/crafts.js index fb74d4c51..241123056 100644 --- a/crafting/crafts.js +++ b/crafting/crafts.js @@ -1,10 +1,73 @@ +function createMaterial(fabricName, fabricUnit, yarnCost) { + var newYarn = { + name: fabricName, + unit: fabricUnit, + costPerUnit: yarnCost + }; + return newYarn +}; + +function calculateMaterialCost(fabric1, noOfYards) { + var totalCost = noOfYards * fabric1.costPerUnit + var material = fabric1.name + var unitType = fabric1.unit + return `${noOfYards} ${unitType}s of ${material} costs $${totalCost}.` +}; + +function createSupplyCloset(fabrics) { + var newCloset = { + supplies: [] + }; + if (fabrics !== undefined) { + for (var i = 0; i < fabrics.length; i++) { + newCloset.supplies.push(fabrics[i].name) + }; + }; + return newCloset +}; + +function addSupply(myCloset, materialInfo) { + var updatedCloset = []; + for (var i = 0; i < myCloset.supplies.length; i++) { + updatedCloset.push(myCloset.supplies[i]) + }; + for (var i = 0; i < myCloset.supplies.length; i++) { + if (!myCloset.supplies.includes(materialInfo.name)) { + updatedCloset.push(materialInfo.name) + } else { + return `You already have ${materialInfo.name} in your closet!` + }; + }; + return updatedCloset +}; + +function createNewProject(materials1, status1) { + if(status1 == undefined) { + status1 = 'not started' + }; + var crossStitch = { + materialsNeeded: materials1, + status: status1 + }; + return crossStitch +}; + +function compareMaterials(myPaintProject, mySupplies1) { + for (var i = 0; i < myPaintProject.materialsNeeded.length; i++) { + if(mySupplies1.supplies.includes(myPaintProject.materialsNeeded[i].name)) { + return 'Yay! You can start this project!' + } else { + return 'Oh no! You need to go shopping before you can start this project!' + }; + }; +}; module.exports = { - // createMaterial, - // calculateMaterialCost, - // createSupplyCloset, - // addSupply, - // createNewProject, - // compareMaterials -} \ No newline at end of file + createMaterial, + calculateMaterialCost, + createSupplyCloset, + addSupply, + createNewProject, + compareMaterials +} diff --git a/elevator/elevator-test.js b/elevator/elevator-test.js index 1a9626228..8456c1d82 100644 --- a/elevator/elevator-test.js +++ b/elevator/elevator-test.js @@ -2,7 +2,7 @@ var assert = require('chai').assert; var { createElevator, changeFloors, dropOffPassenger } = require('./elevator'); describe('Elevator', function() { - it.skip('should create an elevator', function() { + it('should create an elevator', function() { var elevator = createElevator('Empire State Building', 102, 5, ['Stacey', 'Javier', 'Tom']); assert.equal(elevator.building, 'Empire State Building'); @@ -11,13 +11,13 @@ describe('Elevator', function() { assert.deepEqual(elevator.passengers, ['Stacey', 'Javier', 'Tom']); }); - it.skip('should be able to change floors', function() { + it('should be able to change floors', function() { var elevator = createElevator('Empire State Building', 102, 5, []); assert.equal(changeFloors(elevator, 10), 'Taking you to floor 10!'); }); - it.skip('should not be able to change floors if already on that floor', function() { + it('should not be able to change floors if already on that floor', function() { var elevator = createElevator('West High School', 3, 2, ['Sarah', 'Ari']); var message = changeFloors(elevator, 2); @@ -25,7 +25,7 @@ describe('Elevator', function() { assert.equal(message, 'You\'re already on floor 2!'); }); - it.skip('should not be able to take you to a floor that does not exist', function() { + it('should not be able to take you to a floor that does not exist', function() { var elevator = createElevator('West High School', 3, 2, ['Katherine', 'Erika']); var message = changeFloors(elevator, 100); @@ -33,7 +33,7 @@ describe('Elevator', function() { assert.equal(message, 'Floor 100 does not exist!'); }); - it.skip('should be able to drop off passenger', function() { + it('should be able to drop off passenger', function() { var elevator = createElevator('Upper Valley Mall', 4, 1, ['Scott', 'Mark', 'Joey']); var remainingPassengers = dropOffPassenger(elevator, 'Mark'); diff --git a/elevator/elevator.js b/elevator/elevator.js index 8740d66ab..a64881f90 100644 --- a/elevator/elevator.js +++ b/elevator/elevator.js @@ -1,3 +1,34 @@ +function createElevator(building1, floors1, currentFloor1, passengers1) { + var elevator1 = { + building: building1, + floors: floors1, + currentFloor: currentFloor1, + passengers: passengers1 + } + return elevator1 +}; +function changeFloors(elevator, newFloor) { + if(elevator.floors < newFloor) { + return `Floor ${newFloor} does not exist!` + } else if(elevator.currentFloor !== newFloor) { + return `Taking you to floor ${newFloor}!` + } else { + return `You're already on floor ${newFloor}!` + } +}; -module.exports = { }; +function dropOffPassenger(elevator, passengerOff) { + for(var i = 0; i < elevator.passengers.length; i++) { + if(elevator.passengers[i] === passengerOff) { + elevator.passengers.splice(i , 1) + } + } + return elevator.passengers +}; + +module.exports = { + createElevator, + changeFloors, + dropOffPassenger +}; diff --git a/favorite-foods/favorite-foods-test.js b/favorite-foods/favorite-foods-test.js index bc5f7985b..472df8929 100644 --- a/favorite-foods/favorite-foods-test.js +++ b/favorite-foods/favorite-foods-test.js @@ -1,27 +1,27 @@ -var { createFavoriteFood } = require('./favorite-foods'); +var { createFavoriteFood, commentOnSpiciness, orderFood, createShoppingList } = require('./favorite-foods'); var assert = require('chai').assert; describe('favorite foods', function () { - it.skip('should create a new dish with a name', function () { + it('should create a new dish with a name', function () { var pizza = createFavoriteFood({ dish: 'Pizza' }); assert.equal(pizza.name, 'Pizza'); }); - it.skip('should be able to create a different dish', function () { + it('should be able to create a different dish', function () { var smoothie = createFavoriteFood({ dish: 'Smoothie' }); assert.equal(smoothie.name, 'Smoothie'); }); - it.skip('should have ingredients', function () { + it('should have ingredients', function () { var tacos = createFavoriteFood({ dish: 'Tacos', ingredients: ['Tortilla', 'Ground Beef', 'Lettuce', 'Tomatoes', 'Sour Cream', 'Salsa'] }); assert.equal(tacos.name, 'Tacos'); assert.deepEqual(tacos.ingredients, ['Tortilla', 'Ground Beef', 'Lettuce', 'Tomatoes', 'Sour Cream', 'Salsa']); }); - it.skip('should be able to have different ingredients', function () { + it('should be able to have different ingredients', function () { var burger = createFavoriteFood({ dish: 'Burger', ingredients: ['Bun', 'Beef Patty', 'Lettuce', 'Tomato', 'Cheese', 'Ketchup', 'Mustard'] }); var sushi = createFavoriteFood({ dish: 'Sushi', ingredients: ['Rice', 'Salmon', 'Tuna', 'Avocado', 'Cucumber', 'Soy Sauce', 'Wasabi'] }); @@ -32,7 +32,7 @@ describe('favorite foods', function () { assert.deepEqual(sushi.ingredients, ['Rice', 'Salmon', 'Tuna', 'Avocado', 'Cucumber', 'Soy Sauce', 'Wasabi']); }); - it.skip('should be spicy or not', function () { + it('should be spicy or not', function () { var pancakes = createFavoriteFood({ dish: 'Pancakes', ingredients: ['Flour', 'Egg', 'Milk', 'Butter', 'Maple Syrup'], isSpicy: false }); var padThai = createFavoriteFood({ dish: 'Pad Thai', ingredients: ['Rice Noodles', 'Shrimp', 'Tofu', 'Egg', 'Bean Sprouts', 'Peanuts', 'Lime'], isSpicy: true }); @@ -45,7 +45,7 @@ describe('favorite foods', function () { assert.equal(padThai.isSpicy, true); }); - it.skip('should be able to taste the food and comment on how spicy it is', function () { + it('should be able to taste the food and comment on how spicy it is', function () { var dish1 = createFavoriteFood({ dish: 'Pho', ingredients: ['Rice Noodles', 'Beef', 'Bean Sprouts', 'Basil', 'Lime', 'Sriracha'], isSpicy: true }); var dish2 = createFavoriteFood({ dish: 'Lasagna', ingredients: ['Lasagna Noodles', 'Ground Beef', 'Tomato Sauce', 'Ricotta Cheese', 'Mozzarella Cheese'], isSpicy: false }); @@ -56,13 +56,13 @@ describe('favorite foods', function () { assert.equal(comment2, 'Phew, this Lasagna is not very spicy.'); }); - it.skip('should start off having ordered 0 times', function () { + it('should start off having ordered 0 times', function () { var dish = createFavoriteFood('Falafel', ['Chickpeas', 'Garlic', 'Onion', 'Cumin', 'Tahini', 'Pita Bread'], true); assert.equal(dish.timesOrdered, 0); }); - it.skip('should be able to order dishes', function () { + it('should be able to order dishes', function () { var dish1 = createFavoriteFood({ dish: 'Fish and Chips', ingredients: ['Fish Fillet', 'Potatoes', 'Flour', 'Egg', 'Beer', 'Tartar Sauce'], isSpicy: false }); var dish2 = createFavoriteFood({ dish: 'Chicken Curry', ingredients: ['Chicken', 'Coconut Milk', 'Onion', 'Garlic', 'Rice'], isSpicy: true }); var dish3 = createFavoriteFood({ dish: 'Ice Cream', ingredients: ['Milk', 'Cream', 'Sugar', 'Vanilla Extract', 'Chocolate Chips'], isSpicy: false }); @@ -81,7 +81,7 @@ describe('favorite foods', function () { }) // spicy ๐ŸŒถ๏ธ - it.skip('should be able to make a list of all ingredients needed for multiple dishes', function () { + it('should be able to make a list of all ingredients needed for multiple dishes', function () { var pizza = createFavoriteFood({ dish: 'Pizza', ingredients: ['Tomato Sauce', 'Cheese', 'Pepperoni', 'Mushrooms'], isSpicy: false }); var smoothie = createFavoriteFood({ dish: 'Smoothie', ingredients: ['Banana', 'Strawberry', 'Blueberry', 'Milk', 'Honey'], isSpicy: false }) diff --git a/favorite-foods/favorite-foods.js b/favorite-foods/favorite-foods.js index 5f93c3872..e15160ac7 100644 --- a/favorite-foods/favorite-foods.js +++ b/favorite-foods/favorite-foods.js @@ -1,4 +1,39 @@ +function createFavoriteFood(dish) { + var dish = { + name: dish.dish, + ingredients: dish.ingredients, + isSpicy: dish.isSpicy, + timesOrdered: 0 + } + return dish +}; +function commentOnSpiciness(dish) { + if(dish.isSpicy) { + return `Wow, this ${dish.name} is so spicy!` + } + return `Phew, this ${dish.name} is not very spicy.` +}; -module.exports = { }; \ No newline at end of file +function orderFood(dish) { + dish.timesOrdered ++ + return dish +}; + +function createShoppingList(dishes) { + var newList = []; + for(var i = 0; i < dishes.length; i++) { + for(var z = 0; z < dishes[i].ingredients.length; z++) { + newList.push(dishes[i].ingredients[z]) + } + } + return newList +}; + +module.exports = { + createFavoriteFood, + commentOnSpiciness, + orderFood, + createShoppingList +}; \ No newline at end of file diff --git a/meal-planning/mealPlanning-test.js b/meal-planning/mealPlanning-test.js index 22d948df4..a905415a3 100644 --- a/meal-planning/mealPlanning-test.js +++ b/meal-planning/mealPlanning-test.js @@ -2,7 +2,7 @@ var { createMeal, addDish, calculateCalories } = require('./mealPlanning.js'); var assert = require('chai').assert; describe("Meal Planning", function () { - it.skip("should create a meal with a dynamic type and calorie goal", function() { + it("should create a meal with a dynamic type and calorie goal", function() { var easyBreakfast = createMeal('breakfast', 700); var simpleLunch = createMeal("lunch", 400); @@ -12,19 +12,19 @@ describe("Meal Planning", function () { assert.equal(simpleLunch.calorieGoal, 400); }); - it.skip("should default to having no dishes", function() { + it("should default to having no dishes", function() { var breakfast = createMeal('breakfast', 700); assert.deepEqual(breakfast.dishes, []); }); - it.skip("should add a dish to a meal", function() { + it("should add a dish to a meal", function() { var meal = createMeal("dinner", 500); var mealWithSpaghetti = addDish(meal, { name: "spaghetti", calories: 300 }); assert.deepEqual(mealWithSpaghetti.dishes, [{ name: "spaghetti", calories: 300 }]); }); - it.skip("should add another dish to a meal", function() { + it("should add another dish to a meal", function() { var meal = createMeal("dinner", 600); var mealWithSpaghetti = addDish(meal, { name: "spaghetti", calories: 300 }); var mealWithBread = addDish(mealWithSpaghetti, { name: "garlic bread", calories: 200 }); @@ -32,7 +32,7 @@ describe("Meal Planning", function () { assert.deepEqual(mealWithBread.dishes, [{ name: "spaghetti", calories: 300 }, { name: "garlic bread", calories: 200 }]); }); - it.skip("should only add a dish if it meets or is below the meal's calorie goal", function() { + it("should only add a dish if it meets or is below the meal's calorie goal", function() { var meal = createMeal("dinner", 700); var mealWithBread = addDish(meal, { name: "garlic bread", calories: 200 }); @@ -45,7 +45,7 @@ describe("Meal Planning", function () { assert.equal(mealWithPizza.dishes.length, 0); }); - it.skip("should update the calorieGoal when dishes are added", function() { + it("should update the calorieGoal when dishes are added", function() { var meal = createMeal("breakfast", 400); var mealWithEggs = addDish(meal, { name: "eggs", calories: 200 }); @@ -56,17 +56,17 @@ describe("Meal Planning", function () { assert.equal(mealWithPancake.calorieGoal, 20); }); - it.skip("should calculate the total meal calories", function() { + it("should calculate the total meal calories", function() { var brunch = createMeal("brunch", 700); var brunchWithOmelette = addDish(brunch, { name: "omelette", calories: 450 }); var brunchWithFruit = addDish(brunchWithOmelette, { name: "fruit", calories: 100 }); - +console.log('dish:', brunchWithFruit) var totalCalorieCount = calculateCalories(brunchWithFruit); assert.equal(totalCalorieCount, "brunch has a total of 550 calories."); }); - it.skip("should calculate a different meal's calories", function() { + it("should calculate a different meal's calories", function() { var dinner = createMeal("dinner", 1200); var dinnerWithSoup = addDish(dinner, { name: "soup", calories: 250 }); var dinnerWithBeans = addDish(dinnerWithSoup, { name: "green beans", calories: 200 }); diff --git a/meal-planning/mealPlanning.js b/meal-planning/mealPlanning.js index 7334bdcf3..6116f3fac 100644 --- a/meal-planning/mealPlanning.js +++ b/meal-planning/mealPlanning.js @@ -1,2 +1,30 @@ +function createMeal(food, calories) { + var meal = { + type: food, + calorieGoal: calories, + dishes: [] + } + return meal +}; -module.exports = { } \ No newline at end of file +function addDish(meal, dish) { + if(meal.calorieGoal >= dish.calories) { + meal.dishes.push(dish) + meal.calorieGoal -= dish.calories + } + return meal +}; + +function calculateCalories(meal) { + var totalCalories = 0; + for(var i = 0; i < meal.dishes.length; i++) { + totalCalories += meal.dishes[i].calories + } + return `${meal.type} has a total of ${totalCalories} calories.` +}; + +module.exports = { + createMeal, + addDish, + calculateCalories +}; \ No newline at end of file diff --git a/mythical-creatures/exercises/dragon.js b/mythical-creatures/exercises/dragon.js index 0037230de..e00927958 100644 --- a/mythical-creatures/exercises/dragon.js +++ b/mythical-creatures/exercises/dragon.js @@ -1,8 +1,86 @@ +function createDragon (dragonName, riderName, dragonTemperment) { +//1 parameter that takes in a name and returns an object with a key of name +//now 2 parameters, where the second parameter should be the rider's name in the object +//now 3 parameters, where the third parameter should be the dragons temperment in the object + + var dragon1 = { + name: dragonName, + rider: riderName, + temperment: dragonTemperment, + timesEaten: 0, + hungry: true + } + return dragon1 +} + + +function greetRider (dragon) { + // 1 parameter of a variable + // dragon1 variable is being passed through, which invokes my createDragon function + // which will pass my dragon1 object through + //so I need to use dot notation to pull the dragon riders name + var rider1 = dragon.rider + return `Hi, ${rider1}!` + +} + + +function eat (dragonEating) { + // 1 parameter that takes in a variable + // if the dragon times eaten = 3, hungry needs to change to false + var fedDragon1 = dragonEating + for (var i = 0; i < 4; i++) { + if (fedDragon1.timesEaten < 3) { + fedDragon1.timesEaten ++ + } + if (fedDragon1.timesEaten > 2) { + fedDragon1.hungry = false + } + // console.log(fedDragon1) + return fedDragon1 + } +} + +//had to console log the variable in the test to see that it was undefined +//setup a variable and returned that so it pushed back to var fedDragon on the test + +// function eat (dragonEating) { +// //1 parameter that takes in a variable +// //the dragon times eaten = 3, hungry needs to change to false +// for (var i = 0; i < 4; i++) { +// if (dragonEating.timesEaten < 3) { +// dragonEating.timesEaten ++ +// } +// if (dragonEating.timesEaten > 2) { +// dragonEating.hungry = false +// } +// // console.log('DragonImp:', fedDragon1) +// return dragonEating +// } +// } +//this way would also work, but you would need to return the parameter +//rather than creating a variable and returning the variable + +function findFireBreathers(fireBreathers1) { +var index = -1 + + for (var i = 0; i < fireBreathers1.length; i++){ + if (fireBreathers1[i].temperment !== 'aggressive') { + index = i + } + if (index !== -1){ + fireBreathers1.splice(index, 1) + } + } + return fireBreathers1 +}; + + module.exports = { - // createDragon, - // greetRider, - // eat, - // findFireBreathers + createDragon, + greetRider, + eat, + findFireBreathers } \ No newline at end of file diff --git a/mythical-creatures/exercises/hobbit.js b/mythical-creatures/exercises/hobbit.js index 6d9602430..fbaf96a81 100644 --- a/mythical-creatures/exercises/hobbit.js +++ b/mythical-creatures/exercises/hobbit.js @@ -1,9 +1,55 @@ +function createHobbit(name1, age1) { + var hobbit = { + name: name1 || 'unknown', + age: age1 || 0, + isAdult: false, + isOld: false, + acquaintances: [] + } + return hobbit +}; +function celebrateBirthday(hobbit) { + hobbit.age ++; + if(hobbit.age >= 33) { + 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, friend) { + for(var i = 0; i < friend.length; i++) { + hobbit.acquaintances.push(friend[i]); + } + return hobbit; +}; + +function findFriends(hobbit) { + var people = hobbit.acquaintances; + var friends = []; + for(var i = 0; i < people.length; i++) { + if(people[i].relationship === 'friend') { + friends.push(people[i].name); + } + } + return friends +}; module.exports = { - // createHobbit, - // celebrateBirthday, - // getRing, - // meetPeople, - // findFriends + createHobbit, + celebrateBirthday, + getRing, + meetPeople, + findFriends } \ No newline at end of file diff --git a/mythical-creatures/exercises/vampire.js b/mythical-creatures/exercises/vampire.js index 930b9e5cc..1c50b5a90 100644 --- a/mythical-creatures/exercises/vampire.js +++ b/mythical-creatures/exercises/vampire.js @@ -1,9 +1,51 @@ +function createVampire(name1, pet1) { + var vampire1 = { + name: name1, + pet: pet1 || 'bat', + thirsty: true, + ouncesDrank: 0 + }; + return vampire1 +}; +function encounterDeliciousVictim(vampy) { + if(vampy.thirsty) { + return 'I WANT TO SUCK YOUR BLOOD!' + } + return 'No thanks, I am too full.' +}; + +function drink(vampy) { + if(vampy.ouncesDrank < 50) { + vampy.ouncesDrank += 10 + }; + if(vampy.ouncesDrank === 50) { + vampy.thirsty = false + }; + return vampy +}; + +function inquirePlace(destinations, city) { + if(destinations.includes(city)) { + return `Yes, I have spent some time in ${city}.` + } + return `No, I have never been to ${city}.` +}; + +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 -} \ No newline at end of file + createVampire, + drink, + findBatLovers, + encounterDeliciousVictim, + inquirePlace +}; \ No newline at end of file diff --git a/mythical-creatures/test/dragon-test.js b/mythical-creatures/test/dragon-test.js index c5f035bd4..c562309fa 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,16 +94,16 @@ 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'); var dragon4 = createDragon('Lady Vox', 'Emily', 'gentle'); - +console.log ('dragon1:', dragon1) var allDragons = [dragon1, dragon2, dragon3, dragon4]; - +console.log ('allDragons:', allDragons) var fireBreathers = findFireBreathers(allDragons); - +console.log ('fireBreathers:', fireBreathers) assert.deepEqual(fireBreathers, [dragon1, dragon3]) }); }); diff --git a/mythical-creatures/test/hobbit-test.js b/mythical-creatures/test/hobbit-test.js index fa53686c0..c5ba921f6 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'); @@ -91,8 +91,7 @@ describe('Hobbit', function() { assert.deepEqual(bilbo.acquaintances, []); }); - //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'); @@ -104,7 +103,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 +116,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 +137,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'}; @@ -146,7 +145,7 @@ describe('Hobbit', function() { var bilbo = createHobbit('Bilbo'); var socialBilbo = meetPeople(bilbo, [foster, allie, garrett, dustin]) - +console.log('social:', socialBilbo) var friends = findFriends(socialBilbo) assert.equal(friends.length, 2); diff --git a/mythical-creatures/test/vampire-test.js b/mythical-creatures/test/vampire-test.js index 8cf69f524..d96ce254d 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 shout at victim when thirsty', function() { + it('should shout at victim when thirsty', function() { var vampire = createVampire('Andy'); var expectedResponse = 'I WANT TO SUCK YOUR BLOOD!' @@ -39,11 +39,11 @@ describe('Vampire', function() { assert.equal(shout, expectedResponse); }); - it.skip('should start with no ounces of blood drank', function() { + it('should start with no ounces of blood drank', function() { assert.equal(createVampire('Bobby').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); @@ -59,7 +59,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); @@ -72,7 +72,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); @@ -89,7 +89,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); @@ -104,7 +104,7 @@ describe('Vampire', function() { assert.equal(encounterDeliciousVictim(drank5xsVamp), `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'); @@ -113,7 +113,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'); @@ -122,7 +122,7 @@ describe('Vampire', function() { assert.deepEqual(response, expectedResponse); }); - 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'); diff --git a/package-lock.json b/package-lock.json index a14533844..6c29b90e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,288 @@ { "name": "foundations", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "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==", + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "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==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "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==" + }, + "node_modules/chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "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" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "engines": { + "node": "*" + } + }, + "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==" + }, + "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=" + }, + "node_modules/debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dependencies": { + "ms": "2.0.0" + } + }, + "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==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "engines": { + "node": ">=0.3.1" + } + }, + "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=", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "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=", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "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": "*" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "engines": { + "node": ">=4" + } + }, + "node_modules/he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "node_modules/mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "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" + } + }, + "node_modules/mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dependencies": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "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" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "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=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "engines": { + "node": "*" + } + }, + "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==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "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==", + "engines": { + "node": ">=4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + }, "dependencies": { "assertion-error": { "version": "1.1.0", diff --git a/spa/spa-test.js b/spa/spa-test.js index 6255e1e7c..1981fd90a 100644 --- a/spa/spa-test.js +++ b/spa/spa-test.js @@ -3,7 +3,7 @@ var assert = require('chai').assert; describe('Customer', function () { - it.skip('should create a customer', function () { + it('should create a customer', function () { var kayla = createCustomer('Kayla', 100, ['acupuncture', 'seaweed wrap']) var ramiro = createCustomer('Ramiro', 0,[]) assert.equal(kayla.name, 'Kayla') @@ -14,12 +14,12 @@ describe('Customer', function () { assert.deepEqual(ramiro.bookings, []) }) - it.skip('should start with no booked services',function(){ + it('should start with no booked services',function(){ var customer = createCustomer('Leta', 0) assert.deepEqual(customer.bookings, []) }) - it.skip('should greet customers and know if they have been there before (previous bookings)', function () { + it('should greet customers and know if they have been there before (previous bookings)', function () { var nick = createCustomer('Nick', 0, []) var tracey = createCustomer('Tracey', 50, ['facial']) var welcomeNick = greeting(nick) @@ -29,14 +29,14 @@ describe('Customer', function () { assert.equal(welcomeTracey, 'Tracey! Welcome back to Happy Spa') }) - it.skip('should create service', function(){ + it('should create service', function(){ var facialService = createService('facial', 50) var emptyService = createService() assert.deepEqual(facialService, {name: 'facial', cost:50 }) assert.deepEqual(emptyService,'Please provide service name and cost.') }) - it.skip('should book services', function(){ + it('should book services', function(){ var travis = createCustomer('Travis', 10, ['steam room']) var will = createCustomer('Will', 0, []) var massage = createService('massage', 50) @@ -50,7 +50,7 @@ describe('Customer', function () { }) - it.skip('should rack up a bill', function(){ + it('should rack up a bill', function(){ var nik = createCustomer('Nik', 0 , []) var footMassage = createService('foot massage', 65) var facial = createService('facial', 50) @@ -61,7 +61,7 @@ describe('Customer', function () { assert.deepEqual(nikFacial.bill, 115) }) - it.skip('should be able to find which services are affordable based on gift card amount', function(){ + it('should be able to find which services are affordable based on gift card amount', function(){ var allServices = [ {name:'sauna', price:10}, {name:'massage', price:50}, diff --git a/spa/spa.js b/spa/spa.js index b4ae944ac..65d8cb6c1 100644 --- a/spa/spa.js +++ b/spa/spa.js @@ -1,8 +1,50 @@ +function createCustomer(firstName, cost, appointments) { + var customer = { + name: firstName, + bill: cost, + bookings: appointments || [] + } + return customer +}; + +function greeting(patron) { + if(patron.bookings[0]) { + return `${patron.name}! Welcome back to Happy Spa` + } + return `${patron.name}! Welcome to Happy Spa` +}; + +function createService(type, price) { + var service = { + name: type, + cost: price + } + if(!service.name && !service.cost) { + return `Please provide service name and cost.` + } + return service +}; + +function bookServices(customer, service) { + customer.bookings.push(service.name) + customer.bill += service.cost + return customer +}; + +function applyGiftCard(services, giftCard) { + var affordableServices = []; + for(var i = 0; i < services.length; i++) { + if(giftCard >= services[i].price) { + affordableServices.push(services[i].name) + } + } + return affordableServices +}; module.exports = { - // createCustomer, - // greeting, - // createService, - // bookServices, - // applyGiftCard -} + createCustomer, + greeting, + createService, + bookServices, + applyGiftCard +}; diff --git a/spotify/spotify-test.js b/spotify/spotify-test.js index 901e7d126..bf2da4c9c 100644 --- a/spotify/spotify-test.js +++ b/spotify/spotify-test.js @@ -3,31 +3,30 @@ var assert = require('chai').assert; describe('Spotify collections', function() { - it.skip('should create a collection', function() { + it('should create a collection', function() { var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs'); assert.equal(chillHits.name, 'Chill Hits'); assert.equal(chillHits.description, 'A collection of relaxing songs'); assert.deepEqual(chillHits.tracks, []); }); - it.skip('should create track', function() { + it('should create track', function() { var track1 = createTrack('Sunset', 'The Midnight', 270); assert.deepEqual(track1.title,'Sunset'); assert.deepEqual(track1.duration,270); assert.deepEqual(track1.artist, 'The Midnight') }); - it.skip("should return default if nothing is passed", function(){ + it("should return default if nothing is passed", function(){ var emptyTrack = createTrack() assert.deepEqual(emptyTrack, {title:'unknown',artist:'unknown', duration:0, }); }) - it.skip('should only appreciate the talent of Red Hot Chili Peppers', function() { + it('should only appreciate the talent of Red Hot Chili Peppers', function() { var track1 = createTrack('Californication', 'Red Hot Chili Peppers', 321); var track2 = createTrack('Otherside', 'Red Hot Chili Peppers', 255); var track3 = createTrack('Beautiful Day', 'U2', 246); - var review1 = reviewTrack(track1); var review2 = reviewTrack(track2); var review3 = reviewTrack(track3); @@ -37,15 +36,16 @@ describe('Spotify collections', function() { assert.equal(review3, 'I wish this was a Red Hot Chili Peppers song.'); }); - it.skip('should add one track to a collection', function() { + it('should add one track to a collection', function() { var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs'); var track1 = createTrack('Sunset', 'The Midnight', 270); + var chillHitsWith1Track = addTrack(chillHits, track1); assert.deepEqual(chillHitsWith1Track.tracks, [track1]); }); - it.skip('should add tracks to a collection', function() { + it('should add tracks to a collection', function() { var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs'); var track1 = createTrack('Sunset', 'The Midnight', 270); var track2 = createTrack('Dreaming', 'Small Sails', 215); @@ -55,16 +55,17 @@ describe('Spotify collections', function() { assert.deepEqual(chillHitsWith2Track.tracks, [track1, track2]); }); - it.skip('should calculate the total duration of a collection', function() { + it('should calculate the total duration of a collection', function() { var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs'); var track1 = createTrack('Sunset', 'The Midnight', 270); var track2 = createTrack('Dreaming', 'Small Sails', 215); var chillHitsWith1Track = addTrack(chillHits, track1); var chillHitsWith2Track = addTrack(chillHitsWith1Track, track2); + assert.equal(getTotalDuration(chillHitsWith2Track), 485); }); - it.skip('should find tracks by artist in a collection', function() { + it('should find tracks by artist in a collection', function() { var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs'); var track1 = createTrack('Sunset', 'The Midnight', 270); var track2 = createTrack('Dreaming', 'Small Sails', 215); @@ -72,6 +73,7 @@ describe('Spotify collections', function() { var chillHitsWith1Track = addTrack(chillHits, track1); var chillHitsWith2Track = addTrack(chillHitsWith1Track, track2); var chillHitsWith3Track = addTrack(chillHitsWith2Track, track3); + assert.deepEqual(findTracksByArtist(chillHitsWith3Track, 'The Midnight'), [track1, track3]); }); diff --git a/spotify/spotify.js b/spotify/spotify.js index 038214d39..320d41ae4 100644 --- a/spotify/spotify.js +++ b/spotify/spotify.js @@ -1,4 +1,69 @@ +function createCollection(name, description) { + var createCollection = { + name: name, + description: description, + tracks: [] + }; + return createCollection +}; +function createTrack(title1, artist1, duration1) { + var createTrack = { + title: title1, + artist: artist1, + duration: duration1, + }; + if (!title1) { + createTrack.title = 'unknown' + }; + if (!artist1) { + createTrack.artist = 'unknown' + }; + if (!duration1) { + createTrack.duration = 0 + }; + return createTrack +}; - module.exports = { } \ No newline at end of file +function reviewTrack(currentSong) { + var artist = currentSong.artist; + if(artist === 'Red Hot Chili Peppers') { + return `The song ${currentSong.title} rules!` + } else { + return 'I wish this was a Red Hot Chili Peppers song.' + }; +}; + +function addTrack(collection, song) { + var tracks = collection.tracks + tracks.push(song) + return collection +} + +function getTotalDuration(songCollection) { + var songDuration = 0; + for(var i = 0; i < songCollection.tracks.length; i++) { + songDuration += songCollection.tracks[i].duration + }; + return songDuration +}; + +function findTracksByArtist(collection, artist) { + var midNight = []; + for (var i = 0; i < collection.tracks.length; i++) { + if(collection.tracks[i].artist === artist) { + midNight.push(collection.tracks[i]) + }; + }; + return midNight +} + + module.exports = { + createCollection, + createTrack, + reviewTrack, + addTrack, + getTotalDuration, + findTracksByArtist + } \ No newline at end of file diff --git a/tacoStand/tacoStand-test.js b/tacoStand/tacoStand-test.js index f1f776b6a..12de7625f 100644 --- a/tacoStand/tacoStand-test.js +++ b/tacoStand/tacoStand-test.js @@ -3,7 +3,7 @@ var { createIngredient, createTaco, addIngredientToTaco, calculatePrice } = requ describe('taco stand', function() { describe('createIngredient', function() { - it.skip('should take a name and price', function() { + it('should take a name and price', function() { var ingredient1 = createIngredient('chicken', 2.50) var ingredient2 = createIngredient('steak', 3.25) @@ -13,7 +13,7 @@ describe('taco stand', function() { assert.equal(ingredient2.price, 3.25) }) - it.skip('should return an ingredient with defaults if nothing is passed', function() { + it('should return an ingredient with defaults if nothing is passed', function() { var defaultIngredient = createIngredient() assert.equal(defaultIngredient.name, 'unknown') @@ -22,22 +22,22 @@ describe('taco stand', function() { }) describe('createTaco', function() { - it.skip('should have a name', function() { + it('should have a name', function() { assert.equal(createTaco('southwestern').name, 'southwestern') }) - it.skip('should have a default name if none provided', function() { + it('should have a default name if none provided', function() { assert.equal(createTaco().name, 'custom') }) - it.skip('should have no ingredients by default', function() { + it('should have no ingredients by default', function() { assert.deepEqual(createTaco('baja').ingredients, []) }) - it.skip('should be able to create a taco with ingredients', function() { + it('should be able to create a taco with ingredients', function() { var fish = createIngredient('fish', 2.95) var hotSauce = createIngredient('siracha mayo', 0.95) var lettuce = createIngredient('lettuce', 0.50) @@ -50,17 +50,18 @@ describe('taco stand', function() { }) describe('addIngredientToTaco', function() { - it.skip('should be able to add an ingredient to a taco', function() { + it('should be able to add an ingredient to a taco', function() { var steak = createIngredient('steak', 3.50) var basicSteakTaco = createTaco('basic steak', [steak]) var lettuce = createIngredient('lettuce', 0.50) + var lettuceAddedTaco = addIngredientToTaco(basicSteakTaco, lettuce) assert.deepEqual(lettuceAddedTaco.ingredients, [steak, lettuce]) }) - it.skip('should return the taco unchanged if no ingredient is included', function() { + it('should return the taco unchanged if no ingredient is included', function() { var steak = createIngredient('steak', 3.50) var basicSteakTaco = createTaco('basic steak', [steak]) @@ -71,14 +72,14 @@ describe('taco stand', function() { }) describe('calculatePrice', function() { - it.skip('should calculate the price of a single ingredient taco', function() { + it('should calculate the price of a single ingredient taco', function() { var steak = createIngredient('steak', 3.50) var basicSteakTaco = createTaco('basic steak', [steak]) assert.equal(calculatePrice(basicSteakTaco), 3.50) }) - it.skip('should calculate the price of a 2 ingredient taco', function() { + it('should calculate the price of a 2 ingredient taco', function() { var steak = createIngredient('steak', 3.50) var lettuce = createIngredient('lettuce', 0.50) var steakTaco = createTaco('steak', [steak, lettuce]) @@ -86,7 +87,7 @@ describe('taco stand', function() { assert.equal(calculatePrice(steakTaco), 4.00) }) - it.skip('should calculate the price of a many ingredient taco', function() { + it('should calculate the price of a many ingredient taco', function() { var steak = createIngredient('steak', 3.50) var lettuce = createIngredient('lettuce', 0.50) var hotSauce = createIngredient('siracha mayo', 0.95) diff --git a/tacoStand/tacoStand.js b/tacoStand/tacoStand.js index 5704bb728..34f0e04d7 100644 --- a/tacoStand/tacoStand.js +++ b/tacoStand/tacoStand.js @@ -1,2 +1,63 @@ +function createIngredient(ingredient, price1) { + var ingredients = { + name: ingredient, + price: price1 + } + if (ingredients.name == undefined) { + ingredients.name = 'unknown' + } + if (ingredients.price == undefined) { + ingredients.price = 0.00 + } + return ingredients +}; + +function createTaco(tacoName, tacoIngredients) { + var taco = { + name: tacoName, + ingredients: [] + } + if(tacoName == undefined) { + taco.name = 'custom' + } + if (tacoIngredients !== undefined) { + for (var i = 0; i < tacoIngredients.length; i++) { + taco.ingredients.push(tacoIngredients[i]) + } + }; + return taco +}; + +function addIngredientToTaco(madeTaco, additionalItem) { + var newItemOnTaco = { + name: madeTaco.name, + ingredients: [] + } + newItemOnTaco.ingredients.push(madeTaco.ingredients[0]) + if(additionalItem) { + newItemOnTaco.ingredients.push(additionalItem) + } + return newItemOnTaco +}; + +function calculatePrice(tacoOrder) { + var costs = []; + for (var i = 0; i < tacoOrder.ingredients.length; i++){ + costs.push(tacoOrder.ingredients[i].price) + } + var price = 0; + for (var z = 0; z < costs.length; z++) { + price += costs[z] + } + return price +}; + + + +module.exports = { + createIngredient, + createTaco, + addIngredientToTaco, + calculatePrice +}; -module.exports = {} diff --git a/video-games/video-games-test.js b/video-games/video-games-test.js index fab2d6908..2ca277332 100644 --- a/video-games/video-games-test.js +++ b/video-games/video-games-test.js @@ -1,15 +1,15 @@ -var { createPlayer } = require('./video-games'); +var { createPlayer, createLevel, findCoins, defeatPlayer } = require('./video-games'); var assert = require('chai').assert; describe('video games', function () { - it.skip('should create a new player with a name and an age', function () { + it('should create a new player with a name and an age', function () { var player1 = createPlayer('Ace Skateboarder', 19); assert.equal(player1.name, 'Ace Skateboarder'); assert.equal(player1.age, 19); }); - it.skip('should create another player with a name and an age', function () { + it('should create another player with a name and an age', function () { var player1 = createPlayer('Guitar Heroine', 25); var player2 = createPlayer('Time Traveler', 35); @@ -19,7 +19,7 @@ describe('video games', function () { assert.equal(player2.age, 35); }); - it.skip('should create a new player with a unique moveset', function () { + it('should create a new player with a unique moveset', function () { var player1 = createPlayer('Super Skater', 27, ['super jump', 'board smash', 'grind rail']); assert.equal(player1.name, 'Super Skater'); @@ -27,13 +27,13 @@ describe('video games', function () { assert.deepEqual(player1.moveset['super jump', 'board smash', 'grind rail']); }); - it.skip('should be able to create a new level with a name', function () { + it('should be able to create a new level with a name', function () { var level = createLevel('Island Oasis'); assert.equal(level.name, 'Island Oasis'); }); - it.skip('should be able to create a new level with a name and a player', function () { + it('should be able to create a new level with a name and a player', function () { var player1 = createPlayer('The Future Savior', 18, ['time travel', 'combat training', 'futuristic weapon']); var level = createLevel('Zombie Infested City', [player1]); @@ -41,7 +41,7 @@ describe('video games', function () { assert.deepEqual(level.players, [player1]); }); - it.skip('should be able to create a new level with a name and many players', function () { + it('should be able to create a new level with a name and many players', function () { var player1 = createPlayer('Rock Star Rebel', 21, ['power chord', 'stage dive', 'crowd surf']); var player2 = createPlayer('Pro Skater Prodigy', 16, ['360 flip', 'board slide', 'gap transfer']); var level = createLevel('Candy Cane Canyon', [player1, player2]); @@ -50,7 +50,7 @@ describe('video games', function () { assert.deepEqual(level.players, [player1, player2]); }); - it.skip('should initiate a level with a player and 3 lives and 0 coins', function () { + it('should initiate a level with a player and 3 lives and 0 coins', function () { var player1 = createPlayer('Quantum Jumper', 30, ['dimension jump', 'portal creation', 'alternate reality explosion']); var level = createLevel('Carnival of Terror', [player1]); @@ -60,7 +60,7 @@ describe('video games', function () { assert.equal(level.lives, 3); }); - it.skip('should be able to collect coins', function () { + it('should be able to collect coins', function () { var player1 = createPlayer('The Timeless Troubadour', 500, ['piano sonata', 'violin concerto', 'fllamenco guitar']); var level = createLevel('Infernal Inferno of Flames', [player1]); @@ -73,7 +73,7 @@ describe('video games', function () { assert.equal(updatedLevel.coins, 5); }); - it.skip('should add a life when 100 coins are collected', function () { + it('should add a life when 100 coins are collected', function () { var player1 = createPlayer('The Fiery Friar', 50, ['flame spin', 'fire dance', 'smoke screen']); var level = createLevel('Water Temple', [player1]); @@ -87,7 +87,7 @@ describe('video games', function () { assert.equal(level.lives, 4); }); - it.skip('should be able to defeat the player and cost a life', function () { + it('should be able to defeat the player and cost a life', function () { var player1 = createPlayer('Tony Thrasher', 34, ['thrash throw', 'solving mysteries', 'thrash dance']); var level = createLevel('Alien Outpost', [player1]); @@ -100,7 +100,7 @@ describe('video games', function () { assert.equal(updatedLevelPlayerFell.lives, 2); }); - it.skip('should print `GAME OVER` when a player is defeated and has no lives left', function () { + it('should print `GAME OVER` when a player is defeated and has no lives left', function () { var player1 = createPlayer('Ant Cat', 3, ['tiny roar', 'six-legged claws', 'dig tunnel']); var level = createLevel('Alien Outpost', [player1]); diff --git a/video-games/video-games.js b/video-games/video-games.js index 5f93c3872..61dd70750 100644 --- a/video-games/video-games.js +++ b/video-games/video-games.js @@ -1,4 +1,40 @@ +function createPlayer(character, age1, moves) { + var skateboarder = { + name: character, + age: age1, + moveset: moves + } + return skateboarder +}; +function createLevel(name1, players1) { + var level1 = { + name: name1, + players: players1, + coins: 0, + lives: 3 + } + return level1 +}; +function findCoins(level1, coins1) { + level1.coins += coins1 + var increments = Math.floor(level1.coins / 100); + level1.lives += increments + return level1 +}; -module.exports = { }; \ No newline at end of file +function defeatPlayer(level1) { + level1.lives -- + if(level1.lives < 1) { + return `GAME OVER` + } + return level1 +}; + +module.exports = { + createPlayer, + createLevel, + findCoins, + defeatPlayer +}; \ No newline at end of file