From 4e0b62d3fc67dd957f80d013c7811f4a28fc6d75 Mon Sep 17 00:00:00 2001 From: theTrainMan Date: Tue, 23 Feb 2021 21:13:49 +0200 Subject: [PATCH 1/2] Mandatory - 1 - 4 --- mandatory/1-writers.js | 72 ++-- mandatory/2-water-bottle.js | 182 +++++---- mandatory/3-groceries.js | 46 ++- mandatory/4-people-I-know.js | 746 +++++++++++++++++------------------ 4 files changed, 534 insertions(+), 512 deletions(-) diff --git a/mandatory/1-writers.js b/mandatory/1-writers.js index d56af2fb..4266f5dd 100644 --- a/mandatory/1-writers.js +++ b/mandatory/1-writers.js @@ -20,35 +20,34 @@ */ // We've created an array of objects for you here: -let writers = [ - { - firstName: "Virginia", - lastName: "Woolf", - occupation: "writer", - age: 59, - alive: false, - }, - { - firstName: "Zadie", - lastName: "Smith", - occupation: "writer", - age: 41, - alive: true, - }, - { - firstName: "Jane", - lastName: "Austen", - occupation: "writer", - age: 41, - alive: false, - }, - { - firstName: "Bell", - lastName: "Hooks", - occupation: "writer", - age: 64, - alive: true, - }, +let writers = [{ + firstName: "Virginia", + lastName: "Woolf", + occupation: "writer", + age: 59, + alive: false, + }, + { + firstName: "Zadie", + lastName: "Smith", + occupation: "writer", + age: 41, + alive: true, + }, + { + firstName: "Jane", + lastName: "Austen", + occupation: "writer", + age: 41, + alive: false, + }, + { + firstName: "Bell", + lastName: "Hooks", + occupation: "writer", + age: 64, + alive: true, + }, ]; /* @@ -59,7 +58,9 @@ Exercise 1: "Hi, my name is {firstName} {lastName}. I am {age} years old, and work as a {occupation}." */ - +writers.forEach(function(writers) { + console.log(`Hi, my name is ${writers.firstName} ${writers.lastName}. I am ${writers.age} years old, and work as a ${writers.occupation}.`); +}); /* Exercise 2: @@ -68,7 +69,11 @@ Exercise 2: "Writer {firstName} {lastName} died at {age} years old." */ - +writers.forEach(function(writers) { + if (writers.age > 40 && writers.age < 49 && writers.alive === false) { + console.log(`Hi, my name is ${writers.firstName} ${writers.lastName}. I am ${writers.age} years old.`); + } +}); /* Exercise 3: @@ -76,3 +81,8 @@ Exercise 3: "Hi, my name is {firstName} {lastName}. I am {age} years old." */ +writers.forEach(function(writers) { + if (writers.age > 40 && writers.age < 49 && writers.alive === true) { + console.log(`Hi, my name is ${writers.firstName} ${writers.lastName}. I am ${writers.age} years old.`); + } +}); \ No newline at end of file diff --git a/mandatory/2-water-bottle.js b/mandatory/2-water-bottle.js index d8207867..f8693b66 100644 --- a/mandatory/2-water-bottle.js +++ b/mandatory/2-water-bottle.js @@ -21,22 +21,32 @@ You have to implement the missing features according to the specification. // Here is your starting point: let bottle = { - volume: 0, - fillUp: function () { - // calling this function should completely fill your bottle (volume = 100); - }, - pour: function () { - // calling this function should increase your bottle volume by 10 units; - }, - drink: function () { - // calling this function should decrease your bottle volume by 10 units; - }, - isFull: function () { - // this function should return true if your bottle is full; - }, - isEmpty: function () { - // this function should return true if your bottle is empty; - }, + volume: 0, + fillUp: function() { + // calling this function should completely fill your bottle (volume = 100); + return this.volume += 100; + }, + pour: function() { + // calling this function should increase your bottle volume by 10 units; + if (this.volume <= 90) { + return this.volume += 10; + } + }, + drink: function() { + // calling this function should decrease your bottle volume by 10 units; + if (this.colum >= 10) { + return this.volume -= 10; + } + }, + isFull: function() { + // this function should return true if your bottle is full; + return this.volume === 100; + }, + isEmpty: function() { + // this function should return true if your bottle is empty; + return this.volume === 0; + + }, }; /* @@ -66,19 +76,19 @@ bottle.fillUp(); // CHECKS if (bottle.isFull()) { - console.log(`That's correct! Bottle is full.`); + console.log(`That's correct! Bottle is full.`); } else { - failed = true; - console.warn(`Not quite right! Bottle should be full but it is not.`); + failed = true; + console.warn(`Not quite right! Bottle should be full but it is not.`); } if (!bottle.isEmpty()) { - console.log(`That's correct! Bottle isn't empty.`); + console.log(`That's correct! Bottle isn't empty.`); } else { - failed = true; - console.warn( - `Not quite right! Bottle should not be empty but it is already.` - ); + failed = true; + console.warn( + `Not quite right! Bottle should not be empty but it is already.` + ); } // ACTIONS @@ -86,21 +96,21 @@ bottle.pour(); // CHECKS if (bottle.volume === 100) { - console.log( - `That's correct. Bottle is already full water volume cannot go beyond.` - ); -} else { - failed = true; - console.warn( - `Whoops!!! Looks like you've changed your bottle to a bigger one, it went beyond its maximum capacity up to ${bottle.volume} unit.` - ); + console.log( + `That's correct. Bottle is already full water volume cannot go beyond.` + ); +} else { + failed = true; + console.warn( + `Whoops!!! Looks like you've changed your bottle to a bigger one, it went beyond its maximum capacity up to ${bottle.volume} unit.` + ); } if (bottle.isFull()) { - console.log(`That's correct! Bottle is still full.`); + console.log(`That's correct! Bottle is still full.`); } else { - failed = true; - console.warn(`Not quite right! Bottle should be still full but is not.`); + failed = true; + console.warn(`Not quite right! Bottle should be still full but is not.`); } // ACTIONS @@ -110,12 +120,12 @@ bottle.drink(); // CHECKS if (bottle.volume === 70) { - console.log(`That's correct! Water volume is ${bottle.volume}.`); + console.log(`That's correct! Water volume is ${bottle.volume}.`); } else { - failed = true; - console.warn( - `Not quite right! Water volume should be 70 unit instead of ${bottle.volume}.` - ); + failed = true; + console.warn( + `Not quite right! Water volume should be 70 unit instead of ${bottle.volume}.` + ); } // ACTIONS @@ -125,20 +135,20 @@ bottle.drink(); // CHECKS if (!bottle.isFull()) { - console.log(`That's correct! Bottle isn't full.`); + console.log(`That's correct! Bottle isn't full.`); } else { - failed = true; - console.warn(`Not quite right! Bottle should not be full but it is.`); + failed = true; + console.warn(`Not quite right! Bottle should not be full but it is.`); } if (!bottle.isEmpty()) { - console.log(`That's correct! Bottle isn't empty yet.`); + console.log(`That's correct! Bottle isn't empty yet.`); } else { - failed = true; + failed = true; - console.warn( - `Not quite right! Bottle should not be still empty but it is already.` - ); + console.warn( + `Not quite right! Bottle should not be still empty but it is already.` + ); } // ACTIONS @@ -149,23 +159,23 @@ bottle.drink(); // CHECKS if (bottle.isEmpty()) { - console.log(`That's correct! Bottle is finally emptied.`); + console.log(`That's correct! Bottle is finally emptied.`); } else { - failed = true; + failed = true; - console.warn( - `Not quite right. Bottle should be already empty but it is not.` - ); + console.warn( + `Not quite right. Bottle should be already empty but it is not.` + ); } if (bottle.volume === 0) { - console.log(`That's correct! Empty bottle volume is repesented as zero.`); + console.log(`That's correct! Empty bottle volume is repesented as zero.`); } else { - failed = true; + failed = true; - console.warn( - `Not quite right. Volume should be zero instead of ${bottle.volume}.` - ); + console.warn( + `Not quite right. Volume should be zero instead of ${bottle.volume}.` + ); } // ACTIONS @@ -173,19 +183,19 @@ bottle.drink(); // CHECKS if (bottle.volume === 0) { - console.log(`That's correct! Water volume cannot go below zero.`); + console.log(`That's correct! Water volume cannot go below zero.`); } else { - failed = true; + failed = true; - console.warn( - `Whoops!!! Looks like your water volume went negative. Your water volume is ${bottle.volume} unit.` - ); + console.warn( + `Whoops!!! Looks like your water volume went negative. Your water volume is ${bottle.volume} unit.` + ); } if (bottle.isEmpty()) { - console.log(`That's correct! Bottle is still empty.`); + console.log(`That's correct! Bottle is still empty.`); } else { - console.warn(`Not quite right. Bottle should be empty but it is not.`); + console.warn(`Not quite right. Bottle should be empty but it is not.`); } // ACTIONS @@ -193,31 +203,31 @@ bottle.pour(); // CHECKS if (bottle.volume === 10) { - console.log(`That's correct! Water volume is ${bottle.volume}.`); + console.log(`That's correct! Water volume is ${bottle.volume}.`); } else { - failed = true; + failed = true; - console.warn( - `Not quite right! Water volume should be 10 unit instead of ${bottle.volume}.` - ); + console.warn( + `Not quite right! Water volume should be 10 unit instead of ${bottle.volume}.` + ); } if (!bottle.isFull()) { - console.log(`That's correct! Bottle isn't yet full.`); + console.log(`That's correct! Bottle isn't yet full.`); } else { - failed = true; + failed = true; - console.warn(`Not quite right! Bottle should not be full but it is.`); + console.warn(`Not quite right! Bottle should not be full but it is.`); } if (!bottle.isEmpty()) { - console.log(`That's correct! Bottle isn't empty anymore.`); + console.log(`That's correct! Bottle isn't empty anymore.`); } else { - failed = true; + failed = true; - console.warn( - `Not quite right! Bottle should not be empty again but it is still.` - ); + console.warn( + `Not quite right! Bottle should not be empty again but it is still.` + ); } // ACTIONS @@ -225,19 +235,19 @@ bottle.drink(); // CHECKS if (bottle.isEmpty()) { - console.log(`That's correct! Bottle is emptied once more.`); + console.log(`That's correct! Bottle is emptied once more.`); } else { - failed = true; + failed = true; - console.warn(`Not quite right. Bottle should be empty again but it is not.`); + console.warn(`Not quite right. Bottle should be empty again but it is not.`); } console.log(""); if (failed) { - console.log( - "RESULT: Incorrect. Please read what went wrong above and try again" - ); + console.log( + "RESULT: Incorrect. Please read what went wrong above and try again" + ); } else { - console.log("RESULT: Correct! Congratulations!"); -} + console.log("RESULT: Correct! Congratulations!"); +} \ No newline at end of file diff --git a/mandatory/3-groceries.js b/mandatory/3-groceries.js index 35bf3f65..170a9361 100644 --- a/mandatory/3-groceries.js +++ b/mandatory/3-groceries.js @@ -13,13 +13,13 @@ Complete the exercises below. // Here is your let weeklyMealPlan = { - monday: ["Cheese", "Eggs", "Tomato", "Paprika", "Leek"], - tuesday: ["Wrap", "Tuna", "Canned beans", "Cheese", "Carrot", "Aubergine"], - wednesday: ["Orange Juice", "Apple", "Ananas", "Black tea"], - thursday: ["Lamb", "Salt", "Bulgur", "Potato"], - friday: ["Rice milk", "Blueberries", "Porridge", "Banana", "Cinnamon"], - saturday: ["Olive oil", "Potato", "Salmon", "Asparagus"], - sunday: [], + monday: ["Cheese", "Eggs", "Tomato", "Paprika", "Leek"], + tuesday: ["Wrap", "Tuna", "Canned beans", "Cheese", "Carrot", "Aubergine"], + wednesday: ["Orange Juice", "Apple", "Ananas", "Black tea"], + thursday: ["Lamb", "Salt", "Bulgur", "Potato"], + friday: ["Rice milk", "Blueberries", "Porridge", "Banana", "Cinnamon"], + saturday: ["Olive oil", "Potato", "Salmon", "Asparagus"], + sunday: [], }; /* @@ -30,14 +30,22 @@ Exercise 1: */ // Gather all week item names into this array let weeklyGroceriesToBuy = []; - +for (day in weeklyMealPlan) { + weeklyGroceriesToBuy = weeklyGroceriesToBuy.concat(weeklyMealPlan[day]); +} +weeklyGroceriesToBuy = weeklyGroceriesToBuy.filter(function(ingredient, index, array) { + return index === array.indexOf(ingredient); +}) +console.log(weeklyGroceriesToBuy); /* Exercise 2: Loop through your list again, but now only collect the weekend items into the weekendGroceriesToBuy array. Then use console.log() to print out the list. */ // Gather weekend item names into this array -let weekendGroceriesToBuy = []; +let weekendGroceriesToBuy = weeklyMealPlan.saturday.concat(weeklyMealPlan.sunday); + +console.log(weekendGroceriesToBuy); /* Exercise 3: @@ -48,11 +56,17 @@ Exercise 3: */ // Gather daily item counts into this object let numberOfItemsPerWeek = { - monday: 0, - tuesday: 0, - wednesday: 0, - thursday: 0, - friday: 0, - saturday: 0, - sunday: 0, + monday: 0, + tuesday: 0, + wednesday: 0, + thursday: 0, + friday: 0, + saturday: 0, + sunday: 0, }; + +for (let day in weeklyMealPlan) { + numberOfItemsPerWeek[day] = weeklyMealPlan[day].length +} + +console.log(numberOfItemsPerWeek) \ No newline at end of file diff --git a/mandatory/4-people-I-know.js b/mandatory/4-people-I-know.js index 2f223584..4d946b05 100644 --- a/mandatory/4-people-I-know.js +++ b/mandatory/4-people-I-know.js @@ -14,367 +14,356 @@ When you've finished. Continue to the exercises below. */ -let people = [ - { - age: 39, - company: "PEARLESSA", - name: { - first: "Vilma", - last: "Hardy", - }, - email: "vilma.hardy@pearlessa.info", - friends: [ - { - name: "Sally Nielsen", - age: 37, - skills: ["Data", "Strategic", "Problem"], - }, - { - name: "Barber Wooten", - age: 59, - skills: ["Numeracy", "Strategic", "thinking"], - }, - { - name: "Merle Gilbert", - age: 44, - skills: ["thinking", "management", "making"], - }, - { - name: "Norton Spence", - age: 59, - skills: ["Interviewing", "Observation", "Motivation"], - }, - { - name: "Angel Simon", - age: 42, - skills: ["Numeracy", "Strategic", "Research"], - }, - ], - }, - { - age: 39, - company: "PLUTORQUE", - name: { - first: "Aisha", - last: "Gentry", +let people = [{ + age: 39, + company: "PEARLESSA", + name: { + first: "Vilma", + last: "Hardy", + }, + email: "vilma.hardy@pearlessa.info", + friends: [{ + name: "Sally Nielsen", + age: 37, + skills: ["Data", "Strategic", "Problem"], + }, + { + name: "Barber Wooten", + age: 59, + skills: ["Numeracy", "Strategic", "thinking"], + }, + { + name: "Merle Gilbert", + age: 44, + skills: ["thinking", "management", "making"], + }, + { + name: "Norton Spence", + age: 59, + skills: ["Interviewing", "Observation", "Motivation"], + }, + { + name: "Angel Simon", + age: 42, + skills: ["Numeracy", "Strategic", "Research"], + }, + ], }, - email: "aisha.gentry@plutorque.net", - friends: [ - { - name: "Latonya Hogan", - age: 67, - skills: ["Problem", "Sharing", "Project"], - }, - { - name: "Kate Sheppard", - age: 42, - skills: ["Scheduling", "management", "Respect"], - }, - { - name: "Lela Espinoza", - age: 40, - skills: ["management", "Meeting", "Data"], - }, - { - name: "Lindsay Larsen", - age: 20, - skills: ["Numeracy", "Reporting", "management"], - }, - { - name: "Deleon Gallegos", - age: 48, - skills: ["Respect", "Problem", "Decision"], - }, - ], - }, - { - age: 36, - company: "LINGOAGE", - name: { - first: "Mitchell", - last: "Whitfield", + { + age: 39, + company: "PLUTORQUE", + name: { + first: "Aisha", + last: "Gentry", + }, + email: "aisha.gentry@plutorque.net", + friends: [{ + name: "Latonya Hogan", + age: 67, + skills: ["Problem", "Sharing", "Project"], + }, + { + name: "Kate Sheppard", + age: 42, + skills: ["Scheduling", "management", "Respect"], + }, + { + name: "Lela Espinoza", + age: 40, + skills: ["management", "Meeting", "Data"], + }, + { + name: "Lindsay Larsen", + age: 20, + skills: ["Numeracy", "Reporting", "management"], + }, + { + name: "Deleon Gallegos", + age: 48, + skills: ["Respect", "Problem", "Decision"], + }, + ], }, - email: "mitchell.whitfield@lingoage.io", - friends: [ - { - name: "Head Fitzpatrick", - age: 31, - skills: ["People", "Collaboration", "data"], - }, - { - name: "Natasha Campos", - age: 44, - skills: ["Respect", "Critical", "Strategic"], - }, - { - name: "Abby Mclaughlin", - age: 40, - skills: ["analysis", "Planning", "Scheduling"], - }, - { - name: "Kramer Torres", - age: 61, - skills: ["Observation", "Troubleshooting", "Delegating"], - }, - { - name: "Lawrence Tillman", - age: 42, - skills: ["Planning", "thinking", "setting"], - }, - ], - }, - { - age: 24, - company: "MELBACOR", - name: { - first: "Hooper", - last: "Kirk", + { + age: 36, + company: "LINGOAGE", + name: { + first: "Mitchell", + last: "Whitfield", + }, + email: "mitchell.whitfield@lingoage.io", + friends: [{ + name: "Head Fitzpatrick", + age: 31, + skills: ["People", "Collaboration", "data"], + }, + { + name: "Natasha Campos", + age: 44, + skills: ["Respect", "Critical", "Strategic"], + }, + { + name: "Abby Mclaughlin", + age: 40, + skills: ["analysis", "Planning", "Scheduling"], + }, + { + name: "Kramer Torres", + age: 61, + skills: ["Observation", "Troubleshooting", "Delegating"], + }, + { + name: "Lawrence Tillman", + age: 42, + skills: ["Planning", "thinking", "setting"], + }, + ], }, - email: "hooper.kirk@melbacor.me", - friends: [ - { - name: "Clarissa Kirby", - age: 37, - skills: ["management", "making", "Categorizing"], - }, - { - name: "Contreras Ballard", - age: 38, - skills: ["Prioritizing", "Numeracy", "Data"], - }, - { - name: "Wyatt Small", - age: 29, - skills: ["Respect", "Decision", "Sharing"], - }, - { - name: "Mable Mcgee", - age: 44, - skills: ["Sharing", "Decision", "Prioritizing"], - }, - { - name: "Henry Rodgers", - age: 39, - skills: ["thinking", "Communication", "management"], - }, - ], - }, - { - age: 40, - company: "CIPROMOX", - name: { - first: "Sutton", - last: "Quinn", + { + age: 24, + company: "MELBACOR", + name: { + first: "Hooper", + last: "Kirk", + }, + email: "hooper.kirk@melbacor.me", + friends: [{ + name: "Clarissa Kirby", + age: 37, + skills: ["management", "making", "Categorizing"], + }, + { + name: "Contreras Ballard", + age: 38, + skills: ["Prioritizing", "Numeracy", "Data"], + }, + { + name: "Wyatt Small", + age: 29, + skills: ["Respect", "Decision", "Sharing"], + }, + { + name: "Mable Mcgee", + age: 44, + skills: ["Sharing", "Decision", "Prioritizing"], + }, + { + name: "Henry Rodgers", + age: 39, + skills: ["thinking", "Communication", "management"], + }, + ], }, - email: "sutton.quinn@cipromox.ca", - friends: [ - { - name: "Melanie Patterson", + { age: 40, - skills: ["Reporting", "management", "Numeracy"], - }, - { - name: "April Cortez", - age: 69, - skills: ["Observation", "People", "management"], - }, - { - name: "Butler Frederick", - age: 68, - skills: ["Participation", "Data", "solving"], - }, - { - name: "Gill Barlow", - age: 69, - skills: ["Data", "People", "Coordinating"], - }, - { - name: "Rush May", - age: 44, - skills: ["Data", "Multi-tasking", "Research"], - }, - ], - }, - { - age: 21, - company: "ENVIRE", - name: { - first: "Haley", - last: "Knox", + company: "CIPROMOX", + name: { + first: "Sutton", + last: "Quinn", + }, + email: "sutton.quinn@cipromox.ca", + friends: [{ + name: "Melanie Patterson", + age: 40, + skills: ["Reporting", "management", "Numeracy"], + }, + { + name: "April Cortez", + age: 69, + skills: ["Observation", "People", "management"], + }, + { + name: "Butler Frederick", + age: 68, + skills: ["Participation", "Data", "solving"], + }, + { + name: "Gill Barlow", + age: 69, + skills: ["Data", "People", "Coordinating"], + }, + { + name: "Rush May", + age: 44, + skills: ["Data", "Multi-tasking", "Research"], + }, + ], }, - email: "haley.knox@envire.tv", - friends: [ - { - name: "Nannie Reyes", - age: 47, - skills: ["Sharing", "management", "Time"], - }, - { - name: "Sheena Reeves", - age: 18, - skills: ["making", "Strategic", "Sharing"], - }, - { - name: "Stacie Villarreal", - age: 34, - skills: ["Motivation", "Coordinating", "Listening"], - }, - { - name: "Enid Hays", - age: 45, - skills: ["Categorizing", "solving", "Respect"], - }, - { - name: "Pickett Rodriguez", - age: 27, - skills: ["management", "Communication", "management"], - }, - ], - }, - { - age: 28, - company: "PROSELY", - name: { - first: "Brittany", - last: "Jacobson", + { + age: 21, + company: "ENVIRE", + name: { + first: "Haley", + last: "Knox", + }, + email: "haley.knox@envire.tv", + friends: [{ + name: "Nannie Reyes", + age: 47, + skills: ["Sharing", "management", "Time"], + }, + { + name: "Sheena Reeves", + age: 18, + skills: ["making", "Strategic", "Sharing"], + }, + { + name: "Stacie Villarreal", + age: 34, + skills: ["Motivation", "Coordinating", "Listening"], + }, + { + name: "Enid Hays", + age: 45, + skills: ["Categorizing", "solving", "Respect"], + }, + { + name: "Pickett Rodriguez", + age: 27, + skills: ["management", "Communication", "management"], + }, + ], }, - email: "brittany.jacobson@prosely.name", - friends: [ - { - name: "Glass Weaver", - age: 64, - skills: ["Listening", "making", "Flexibility"], - }, - { - name: "Brandi Dennis", - age: 51, - skills: ["Scheduling", "Motivation", "Interviewing"], - }, - { - name: "Lynch Johnston", - age: 68, - skills: ["data", "Decision", "Interviewing"], - }, - { - name: "Gena Good", - age: 54, - skills: ["Motivation", "management", "Multi-tasking"], - }, - { - name: "Baldwin Wyatt", - age: 61, - skills: ["Advising", "deadlines", "Strategic"], - }, - ], - }, - { - age: 36, - company: "CAPSCREEN", - name: { - first: "Jana", - last: "Harrison", + { + age: 28, + company: "PROSELY", + name: { + first: "Brittany", + last: "Jacobson", + }, + email: "brittany.jacobson@prosely.name", + friends: [{ + name: "Glass Weaver", + age: 64, + skills: ["Listening", "making", "Flexibility"], + }, + { + name: "Brandi Dennis", + age: 51, + skills: ["Scheduling", "Motivation", "Interviewing"], + }, + { + name: "Lynch Johnston", + age: 68, + skills: ["data", "Decision", "Interviewing"], + }, + { + name: "Gena Good", + age: 54, + skills: ["Motivation", "management", "Multi-tasking"], + }, + { + name: "Baldwin Wyatt", + age: 61, + skills: ["Advising", "deadlines", "Strategic"], + }, + ], }, - email: "jana.harrison@capscreen.co.uk", - friends: [ - { - name: "Stacie Villarreal", - age: 34, - skills: ["Motivation", "Coordinating", "Listening"], - }, - { - name: "Dolly Hubbard", - age: 55, - skills: ["Coordinating", "Diplomacy", "Motivation"], - }, - { - name: "Cunningham Shelton", - age: 39, - skills: ["Prioritizing", "Multi-tasking", "Diplomacy"], - }, - { - name: "Gabriela Nunez", - age: 31, - skills: ["Data", "Goal", "management"], - }, - { - name: "Castro Castaneda", - age: 63, - skills: ["Multi-tasking", "Reporting", "making"], - }, - ], - }, - { - age: 31, - company: "POWERNET", - name: { - first: "Gloria", - last: "Hall", - }, - email: "gloria.hall@powernet.com", - friends: [ - { - name: "Lourdes Barr", - age: 65, - skills: ["Scheduling", "Delegating", "thinking"], - }, - { - name: "Luz Newton", - age: 21, - skills: ["Advising", "Multi-tasking", "Sharing"], - }, - { - name: "Kelli Holloway", - age: 46, - skills: ["Respect", "Collaboration", "Research"], - }, - { - name: "Silvia Bean", - age: 32, - skills: ["Data", "Motivation", "Goal"], - }, - { - name: "Cherie Ramirez", + { age: 36, - skills: ["Advising", "Categorizing", "Communication"], - }, - ], - }, - { - age: 22, - company: "POWERNET", - name: { - first: "Clay", - last: "Livingston", + company: "CAPSCREEN", + name: { + first: "Jana", + last: "Harrison", + }, + email: "jana.harrison@capscreen.co.uk", + friends: [{ + name: "Stacie Villarreal", + age: 34, + skills: ["Motivation", "Coordinating", "Listening"], + }, + { + name: "Dolly Hubbard", + age: 55, + skills: ["Coordinating", "Diplomacy", "Motivation"], + }, + { + name: "Cunningham Shelton", + age: 39, + skills: ["Prioritizing", "Multi-tasking", "Diplomacy"], + }, + { + name: "Gabriela Nunez", + age: 31, + skills: ["Data", "Goal", "management"], + }, + { + name: "Castro Castaneda", + age: 63, + skills: ["Multi-tasking", "Reporting", "making"], + }, + ], }, - email: "clay.livingston@powernet.com", - friends: [ - { - name: "Stacie Villarreal", - age: 34, - skills: ["Motivation", "Coordinating", "Listening"], - }, - { - name: "Roy Lynn", + { age: 31, - skills: ["Project", "management", "Goal"], - }, - { - name: "Stacey Vaughan", - age: 29, - skills: ["Prioritizing", "Categorizing", "Observation"], - }, - { - name: "Bradshaw Watts", - age: 66, - skills: ["Decision", "Diplomacy", "Collaboration"], - }, - { - name: "Lee Warren", - age: 27, - skills: ["Strategic", "Advising", "management"], - }, - ], - }, + company: "POWERNET", + name: { + first: "Gloria", + last: "Hall", + }, + email: "gloria.hall@powernet.com", + friends: [{ + name: "Lourdes Barr", + age: 65, + skills: ["Scheduling", "Delegating", "thinking"], + }, + { + name: "Luz Newton", + age: 21, + skills: ["Advising", "Multi-tasking", "Sharing"], + }, + { + name: "Kelli Holloway", + age: 46, + skills: ["Respect", "Collaboration", "Research"], + }, + { + name: "Silvia Bean", + age: 32, + skills: ["Data", "Motivation", "Goal"], + }, + { + name: "Cherie Ramirez", + age: 36, + skills: ["Advising", "Categorizing", "Communication"], + }, + ], + }, + { + age: 22, + company: "POWERNET", + name: { + first: "Clay", + last: "Livingston", + }, + email: "clay.livingston@powernet.com", + friends: [{ + name: "Stacie Villarreal", + age: 34, + skills: ["Motivation", "Coordinating", "Listening"], + }, + { + name: "Roy Lynn", + age: 31, + skills: ["Project", "management", "Goal"], + }, + { + name: "Stacey Vaughan", + age: 29, + skills: ["Prioritizing", "Categorizing", "Observation"], + }, + { + name: "Bradshaw Watts", + age: 66, + skills: ["Decision", "Diplomacy", "Collaboration"], + }, + { + name: "Lee Warren", + age: 27, + skills: ["Strategic", "Advising", "management"], + }, + ], + }, ]; /* @@ -386,7 +375,7 @@ First, I want you to find all of my friends who are 35 or older. */ -let thirtyFiveOrOlder = []; +let thirtyFiveOrOlder = people.filter(friend => friend.age >= 35) /* 3) Find the email address @@ -395,7 +384,7 @@ Next, I want you to find all of the people who work for "POWERNET" and then stor */ -let powerNetEmails = []; +let powerNetEmails = people.filter(friend => friend.company === 'POWERNET').map(post => post.email).sort() /* @@ -409,21 +398,20 @@ This time, I only want the full names of the people are who friends with her. */ -let friendsWithStacie = []; +let friendsOfStacie = people.filter(person => person.friends.find(friend => friend.name === 'Stacie Villarreal')) + /* -/* - -4) Find "Multi-tasking" friends + 4) Find "Multi-tasking" friends -Next, I want you to find all of my friends of friends who are good at "Multi-tasking" + Next, I want you to find all of my friends of friends who are good at "Multi-tasking" -You can tell if they are good at "Multi-tasking" because they will have it listed in their skills + You can tell if they are good at "Multi-tasking" because they will have it listed in their skills -This time, I only want the full names of the people who can multitask + This time, I only want the full names of the people who can multitask -*/ + */ -let friendsWhoCanMultitask = []; +let findMultiTask = people.map(person => person.friends.filter(friend => friend.skills.includes('Multi-tasking'))).flat() /* ================================================== @@ -433,36 +421,36 @@ let friendsWhoCanMultitask = []; const util = require("util"); function test(test_name, actual, expected) { - let status; + let status; - if (actual.toString() === expected.toString()) { - status = "PASSED"; - } else { - status = `FAILED: expected: ${util.inspect( + if (actual.toString() === expected.toString()) { + status = "PASSED"; + } else { + status = `FAILED: expected: ${util.inspect( expected )} but your function returned: ${util.inspect(actual)}`; - } + } - console.log(`${test_name}: ${status}`); + console.log(`${test_name}: ${status}`); } test("Friends are over 35", thirtyFiveOrOlder.length, 5); test("Friends with Stacie Villarreal", friendsWithStacie, [ - "Clay Livingston", - "Jana Harrison", - "Haley Knox", + "Clay Livingston", + "Jana Harrison", + "Haley Knox", ]); test("Powernet email addresses", powerNetEmails, [ - "clay.livingston@powernet.com", - "gloria.hall@powernet.com", + "clay.livingston@powernet.com", + "gloria.hall@powernet.com", ]); test("Friends who can multitask", friendsWhoCanMultitask, [ - "Rush May", - "Gena Good", - "Cunningham Shelton", - "Castro Castaneda", - "Luz Newton", -]); + "Rush May", + "Gena Good", + "Cunningham Shelton", + "Castro Castaneda", + "Luz Newton", +]); \ No newline at end of file From 41d27dae09f949aabf8ada75feeca127871e2592 Mon Sep 17 00:00:00 2001 From: theTrainMan Date: Tue, 16 Mar 2021 12:48:37 +0200 Subject: [PATCH 2/2] All Mandatory --- mandatory/1-writers.js | 6 + mandatory/2-water-bottle.js | 2 +- mandatory/3-groceries.js | 3 +- mandatory/4-people-I-know.js | 4 +- mandatory/5-recipes.js | 35 ++- mandatory/6-reading-list.js | 30 +- mandatory/7-budgets.js | 587 ++++++++++++++++++----------------- mandatory/8-cheap-diner.js | 76 +++-- 8 files changed, 413 insertions(+), 330 deletions(-) diff --git a/mandatory/1-writers.js b/mandatory/1-writers.js index 4266f5dd..34e565f7 100644 --- a/mandatory/1-writers.js +++ b/mandatory/1-writers.js @@ -61,6 +61,12 @@ Exercise 1: writers.forEach(function(writers) { console.log(`Hi, my name is ${writers.firstName} ${writers.lastName}. I am ${writers.age} years old, and work as a ${writers.occupation}.`); }); + +function hello(arr) { + console.log(`Hello, my name is ${arr.map([firstName])}`); + +} + /* Exercise 2: diff --git a/mandatory/2-water-bottle.js b/mandatory/2-water-bottle.js index f8693b66..f436a1fc 100644 --- a/mandatory/2-water-bottle.js +++ b/mandatory/2-water-bottle.js @@ -34,7 +34,7 @@ let bottle = { }, drink: function() { // calling this function should decrease your bottle volume by 10 units; - if (this.colum >= 10) { + if (this.volume >= 10) { return this.volume -= 10; } }, diff --git a/mandatory/3-groceries.js b/mandatory/3-groceries.js index 170a9361..ce82d3f7 100644 --- a/mandatory/3-groceries.js +++ b/mandatory/3-groceries.js @@ -37,6 +37,8 @@ weeklyGroceriesToBuy = weeklyGroceriesToBuy.filter(function(ingredient, index, a return index === array.indexOf(ingredient); }) console.log(weeklyGroceriesToBuy); + + /* Exercise 2: Loop through your list again, but now only collect the weekend items into the weekendGroceriesToBuy array. @@ -44,7 +46,6 @@ Exercise 2: */ // Gather weekend item names into this array let weekendGroceriesToBuy = weeklyMealPlan.saturday.concat(weeklyMealPlan.sunday); - console.log(weekendGroceriesToBuy); /* diff --git a/mandatory/4-people-I-know.js b/mandatory/4-people-I-know.js index 4d946b05..42b65d05 100644 --- a/mandatory/4-people-I-know.js +++ b/mandatory/4-people-I-know.js @@ -398,7 +398,7 @@ This time, I only want the full names of the people are who friends with her. */ -let friendsOfStacie = people.filter(person => person.friends.find(friend => friend.name === 'Stacie Villarreal')) +let friendsWithStacie = people.filter(person => person.friends.find(friend => friend.name === 'Stacie Villarreal')) /* 4) Find "Multi-tasking" friends @@ -411,7 +411,7 @@ let friendsOfStacie = people.filter(person => person.friends.find(friend => frie */ -let findMultiTask = people.map(person => person.friends.filter(friend => friend.skills.includes('Multi-tasking'))).flat() +let friendsWhoCanMultitask = people.map(person => person.friends.filter(friend => friend.skills.includes('Multi-tasking'))).flat() /* ================================================== diff --git a/mandatory/5-recipes.js b/mandatory/5-recipes.js index 4c07f439..5b1b9071 100644 --- a/mandatory/5-recipes.js +++ b/mandatory/5-recipes.js @@ -24,4 +24,37 @@ You should write and log at least 5 recipes **/ -let recipes = {}; +let recipes = [{ + Title: "Curry", + Servings: 6, + Ingredients: ["Onions", 'Potatoes', 'Chicken', 'Tomatoes', 'Peas', 'Coconut Milk', 'Rice', 'olive oil'] + + }, + { + Title: "Chicken fajitas", + Servings: 3, + Ingredients: ["chicken ", "onion ", "red pepper ", + "red chilli ", "paprika ", "coriander ", + "tortillas ", "garlic ", "olive oil" + ] + }, + { + Title: "Carrot cake", + Servings: 10, + Ingredients: [" plain yogurt", "6 eggs", "orange zested", + "self-raising flour", "light muscovado sugar", "cinnamon", + "nutmeg", 'peeled carrots', 'mixed raisins' + ] + }, + { + Title: "Chocolate Cake", + Servings: 8, + Ingredients: ['Flour', 'Cocoa Powder', '5 eggs', 'baking powder', 'olive oil', 'water'] + } +]; + +for (recipe of recipes) { + console.log(recipe.Title); + console.log(`Serves: ${recipe.Servings}`); + console.log(`Ingredients: ${recipe.Ingredients}\n`); +} \ No newline at end of file diff --git a/mandatory/6-reading-list.js b/mandatory/6-reading-list.js index b0b3477e..4cbf9335 100644 --- a/mandatory/6-reading-list.js +++ b/mandatory/6-reading-list.js @@ -23,4 +23,32 @@ and if not, log a string like 'You still need to read "The Lord of the Rings" by **/ -let books = []; +let books = [{ + Title: "The Shack", + Author: "William p young", + Read: true + }, + { + Title: "The Ninja", + Author: "Eric Van Lustbader", + Read: true + }, + { + Title: "The Bourne Deception", + Author: "Eric Van Lustbader & Robert Ludlum", + Read: false + }, + { + Title: "Redeeming love", + Author: "Francine rivers", + Read: true + } +]; + +for (book of books) { + if (book.Read === true) { + console.log(`You've already read ${book.Title} by ${book.Author}`); + } else { + console.log(`You still need to read ${book.Title} by ${book.Author}`); + } +} \ No newline at end of file diff --git a/mandatory/7-budgets.js b/mandatory/7-budgets.js index 787c8433..a1b5b8bf 100644 --- a/mandatory/7-budgets.js +++ b/mandatory/7-budgets.js @@ -16,7 +16,13 @@ Should give return the answer of 62600. **/ -function getBudgets(peopleArray) {} +function getBudgets(peopleArray) { + let sumOfTheBudget = 0; + for (person of peopleArray) { + sumOfTheBudget += person.budget; + } + return sumOfTheBudget; +} /* ================================================== @@ -26,314 +32,313 @@ function getBudgets(peopleArray) {} const util = require("util"); function test(test_name, actual, expected) { - let status; + let status; - if (actual === expected) { - status = "PASSED"; - } else { - status = `FAILED: expected: ${util.inspect( + if (actual === expected) { + status = "PASSED"; + } else { + status = `FAILED: expected: ${util.inspect( expected )} but your function returned: ${util.inspect(actual)}`; - } + } - console.log(`${test_name}: ${status}`); + console.log(`${test_name}: ${status}`); } test("No Budgets", getBudgets([]), 0); test( - "Test 1", - getBudgets([ - { name: "John", age: 21, budget: 23000 }, - { name: "Steve", age: 32, budget: 40000 }, - { name: "Martin", age: 16, budget: 2700 }, - ]), - 65700 + "Test 1", + getBudgets([ + { name: "John", age: 21, budget: 23000 }, + { name: "Steve", age: 32, budget: 40000 }, + { name: "Martin", age: 16, budget: 2700 }, + ]), + 65700 ); test( - "Test 2", - getBudgets([ - { name: "John", age: 21, budget: 29000 }, - { name: "Steve", age: 32, budget: 32000 }, - { name: "Martin", age: 16, budget: 1600 }, - ]), - 62600 + "Test 2", + getBudgets([ + { name: "John", age: 21, budget: 29000 }, + { name: "Steve", age: 32, budget: 32000 }, + { name: "Martin", age: 16, budget: 1600 }, + ]), + 62600 ); test( - "Test 3", - getBudgets([ - { name: "John", age: 21, budget: 19401 }, - { name: "Steve", age: 32, budget: 12321 }, - { name: "Martin", age: 16, budget: 1204 }, - ]), - 32926 + "Test 3", + getBudgets([ + { name: "John", age: 21, budget: 19401 }, + { name: "Steve", age: 32, budget: 12321 }, + { name: "Martin", age: 16, budget: 1204 }, + ]), + 32926 ); test( - "Test 4", - getBudgets([ - { name: "John", age: 21, budget: 10234 }, - { name: "Steve", age: 32, budget: 21754 }, - { name: "Martin", age: 16, budget: 4935 }, - ]), - 36923 + "Test 4", + getBudgets([ + { name: "John", age: 21, budget: 10234 }, + { name: "Steve", age: 32, budget: 21754 }, + { name: "Martin", age: 16, budget: 4935 }, + ]), + 36923 ); test( - "Huge List", - getBudgets([ - { - name: "Reba", - age: 73, - budget: 9657, - }, - { - name: "Tessa", - age: 77, - budget: 2585, - }, - { - name: "Margery", - age: 48, - budget: 2269, - }, - { - name: "Manuela", - age: 75, - budget: 4761, - }, - { - name: "Sanders", - age: 52, - budget: 5652, - }, - { - name: "Bettye", - age: 66, - budget: 8335, - }, - { - name: "Walton", - age: 31, - budget: 7092, - }, - { - name: "Karyn", - age: 41, - budget: 8962, - }, - { - name: "Nora", - age: 31, - budget: 8354, - }, - { - name: "Barlow", - age: 77, - budget: 3438, - }, - { - name: "Iva", - age: 61, - budget: 4806, - }, - { - name: "Marcia", - age: 34, - budget: 10104, - }, - { - name: "Russo", - age: 23, - budget: 1602, - }, - { - name: "Cortez", - age: 51, - budget: 4253, - }, - { - name: "Zimmerman", - age: 43, - budget: 4239, - }, - { - name: "Renee", - age: 75, - budget: 9077, - }, - { - name: "Caroline", - age: 33, - budget: 8301, - }, - { - name: "Grant", - age: 49, - budget: 9942, - }, - { - name: "Tammi", - age: 58, - budget: 7447, - }, - { - name: "Mayra", - age: 73, - budget: 3500, - }, - { - name: "Goodwin", - age: 28, - budget: 4223, - }, - { - name: "Cathryn", - age: 57, - budget: 2517, - }, - { - name: "Stuart", - age: 20, - budget: 8208, - }, - { - name: "Lina", - age: 45, - budget: 5131, - }, - { - name: "Hampton", - age: 62, - budget: 3423, - }, - { - name: "Coleen", - age: 49, - budget: 5377, - }, - { - name: "Jamie", - age: 56, - budget: 8361, - }, - { - name: "Brigitte", - age: 77, - budget: 1460, - }, - { - name: "Colette", - age: 41, - budget: 3419, - }, - { - name: "Susan", - age: 45, - budget: 8097, - }, - { - name: "Shaffer", - age: 75, - budget: 3883, - }, - { - name: "Clements", - age: 74, - budget: 3141, - }, - { - name: "Cobb", - age: 58, - budget: 6058, - }, - { - name: "Ochoa", - age: 25, - budget: 7916, - }, - { - name: "Anita", - age: 72, - budget: 2678, - }, - { - name: "Carolyn", - age: 51, - budget: 2781, - }, - { - name: "Beard", - age: 72, - budget: 9433, - }, - { - name: "Bender", - age: 26, - budget: 8824, - }, - { - name: "Rich", - age: 37, - budget: 3312, - }, - { - name: "Angelina", - age: 48, - budget: 8997, - }, - { - name: "Cecelia", - age: 30, - budget: 5044, - }, - { - name: "Nixon", - age: 59, - budget: 5178, - }, - { - name: "Alana", - age: 30, - budget: 7976, - }, - { - name: "Mcconnell", - age: 54, - budget: 2419, - }, - { - name: "Cunningham", - age: 21, - budget: 5659, - }, - { - name: "Concetta", - age: 58, - budget: 8269, - }, - { - name: "Natalie", - age: 27, - budget: 3078, - }, - { - name: "Lee", - age: 46, - budget: 3743, - }, - { - name: "Monica", - age: 18, - budget: 8701, - }, - { - name: "Lauri", - age: 61, - budget: 7849, - }, - ]), - 289531 -); + "Huge List", + getBudgets([{ + name: "Reba", + age: 73, + budget: 9657, + }, + { + name: "Tessa", + age: 77, + budget: 2585, + }, + { + name: "Margery", + age: 48, + budget: 2269, + }, + { + name: "Manuela", + age: 75, + budget: 4761, + }, + { + name: "Sanders", + age: 52, + budget: 5652, + }, + { + name: "Bettye", + age: 66, + budget: 8335, + }, + { + name: "Walton", + age: 31, + budget: 7092, + }, + { + name: "Karyn", + age: 41, + budget: 8962, + }, + { + name: "Nora", + age: 31, + budget: 8354, + }, + { + name: "Barlow", + age: 77, + budget: 3438, + }, + { + name: "Iva", + age: 61, + budget: 4806, + }, + { + name: "Marcia", + age: 34, + budget: 10104, + }, + { + name: "Russo", + age: 23, + budget: 1602, + }, + { + name: "Cortez", + age: 51, + budget: 4253, + }, + { + name: "Zimmerman", + age: 43, + budget: 4239, + }, + { + name: "Renee", + age: 75, + budget: 9077, + }, + { + name: "Caroline", + age: 33, + budget: 8301, + }, + { + name: "Grant", + age: 49, + budget: 9942, + }, + { + name: "Tammi", + age: 58, + budget: 7447, + }, + { + name: "Mayra", + age: 73, + budget: 3500, + }, + { + name: "Goodwin", + age: 28, + budget: 4223, + }, + { + name: "Cathryn", + age: 57, + budget: 2517, + }, + { + name: "Stuart", + age: 20, + budget: 8208, + }, + { + name: "Lina", + age: 45, + budget: 5131, + }, + { + name: "Hampton", + age: 62, + budget: 3423, + }, + { + name: "Coleen", + age: 49, + budget: 5377, + }, + { + name: "Jamie", + age: 56, + budget: 8361, + }, + { + name: "Brigitte", + age: 77, + budget: 1460, + }, + { + name: "Colette", + age: 41, + budget: 3419, + }, + { + name: "Susan", + age: 45, + budget: 8097, + }, + { + name: "Shaffer", + age: 75, + budget: 3883, + }, + { + name: "Clements", + age: 74, + budget: 3141, + }, + { + name: "Cobb", + age: 58, + budget: 6058, + }, + { + name: "Ochoa", + age: 25, + budget: 7916, + }, + { + name: "Anita", + age: 72, + budget: 2678, + }, + { + name: "Carolyn", + age: 51, + budget: 2781, + }, + { + name: "Beard", + age: 72, + budget: 9433, + }, + { + name: "Bender", + age: 26, + budget: 8824, + }, + { + name: "Rich", + age: 37, + budget: 3312, + }, + { + name: "Angelina", + age: 48, + budget: 8997, + }, + { + name: "Cecelia", + age: 30, + budget: 5044, + }, + { + name: "Nixon", + age: 59, + budget: 5178, + }, + { + name: "Alana", + age: 30, + budget: 7976, + }, + { + name: "Mcconnell", + age: 54, + budget: 2419, + }, + { + name: "Cunningham", + age: 21, + budget: 5659, + }, + { + name: "Concetta", + age: 58, + budget: 8269, + }, + { + name: "Natalie", + age: 27, + budget: 3078, + }, + { + name: "Lee", + age: 46, + budget: 3743, + }, + { + name: "Monica", + age: 18, + budget: 8701, + }, + { + name: "Lauri", + age: 61, + budget: 7849, + }, + ]), + 289531 +); \ No newline at end of file diff --git a/mandatory/8-cheap-diner.js b/mandatory/8-cheap-diner.js index a7032c5b..72f82d20 100644 --- a/mandatory/8-cheap-diner.js +++ b/mandatory/8-cheap-diner.js @@ -30,7 +30,17 @@ Should give the answer "Nothing :(" **/ function chooseMeal(mealArray) { - // Write your code here + // Write your code here + mealArray.sort((a, b) => a.price - b.price); + if (mealArray.length === 0) { + return 'Nothing'; + } else if (mealArray.length === 1) { + return mealArray[0].name + } else { + if (mealArray.length == 2) { + return mealArray[1].name + } + } } /* @@ -41,36 +51,36 @@ function chooseMeal(mealArray) { const util = require("util"); function test(test_name, actual, expected) { - let status; + let status; - if (actual === expected) { - status = `PASSED! You got the correct answer of ${util.inspect(expected)}`; - } else { - status = `FAILED: expected: ${util.inspect( + if (actual === expected) { + status = `PASSED! You got the correct answer of ${util.inspect(expected)}`; + } else { + status = `FAILED: expected: ${util.inspect( expected )} but your function returned: ${util.inspect(actual)}`; - } + } - console.log(`${test_name}: ${status}`); + console.log(`${test_name}: ${status}`); } test( - "Test 1", - chooseMeal([ - { name: "Dunkin' Donuts", price: 8.99 }, - { name: "Captain D's", price: 13.99 }, - { name: "Moe's Southwest Grill", price: 10.99 }, - ]), - "Moe's Southwest Grill" + "Test 1", + chooseMeal([ + { name: "Dunkin' Donuts", price: 8.99 }, + { name: "Captain D's", price: 13.99 }, + { name: "Moe's Southwest Grill", price: 10.99 }, + ]), + "Moe's Southwest Grill" ); test( - "Test 2", - chooseMeal([ - { name: "Burger King", price: 8.99 }, - { name: "Wingstop", price: 9.99 }, - ]), - "Wingstop" + "Test 2", + chooseMeal([ + { name: "Burger King", price: 8.99 }, + { name: "Wingstop", price: 9.99 }, + ]), + "Wingstop" ); test("Test 3", chooseMeal([{ name: "Subway", price: 8.99 }]), "Subway"); @@ -78,18 +88,18 @@ test("Test 3", chooseMeal([{ name: "Subway", price: 8.99 }]), "Subway"); test("Test 4", chooseMeal([]), "Nothing :("); test( - "Test 5", - chooseMeal([ - { name: "Church's Chicken", price: 8.99 }, - { name: "Smoothie King", price: 109.99 }, - { name: "Jamba Juice", price: 38.44 }, - { name: "Jason's Deli", price: 22.77 }, - ]), - "Jason's Deli" + "Test 5", + chooseMeal([ + { name: "Church's Chicken", price: 8.99 }, + { name: "Smoothie King", price: 109.99 }, + { name: "Jamba Juice", price: 38.44 }, + { name: "Jason's Deli", price: 22.77 }, + ]), + "Jason's Deli" ); test( - "Test 6", - chooseMeal([{ name: "Church's Chicken", price: 8.99 }]), - "Church's Chicken" -); + "Test 6", + chooseMeal([{ name: "Church's Chicken", price: 8.99 }]), + "Church's Chicken" +); \ No newline at end of file