From 7b324bd4679f4a808dac1eb205014dfd6b32f20b Mon Sep 17 00:00:00 2001 From: Louise Chow Date: Sun, 16 Aug 2020 17:59:09 +0100 Subject: [PATCH 01/10] Add homework exercises for array destructuring + remove class exercises --- .../mandatory/2-exercises/1-shopping-cart.js | 26 ---------- .../mandatory/2-exercises/2-convertion.js | 30 ----------- .../Homework/mandatory/2-exercises/3-atm.js | 25 ---------- .../mandatory/2-exercises/4-music-player.js | 50 ------------------- .../2-exercises/exercise-1/exercise-1.js | 11 ++++ .../2-exercises/exercise-1/exercise-1.md | 20 ++++++++ .../2-exercises/exercise-2/exercise-2.js | 12 +++++ .../2-exercises/exercise-2/exercise-2.md | 32 ++++++++++++ .../2-exercises/exercise-3/exercise-3.js | 11 ++++ .../2-exercises/exercise-3/exercise-3.md | 18 +++++++ 10 files changed, 104 insertions(+), 131 deletions(-) delete mode 100644 week-3/Homework/mandatory/2-exercises/1-shopping-cart.js delete mode 100644 week-3/Homework/mandatory/2-exercises/2-convertion.js delete mode 100644 week-3/Homework/mandatory/2-exercises/3-atm.js delete mode 100644 week-3/Homework/mandatory/2-exercises/4-music-player.js create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js create mode 100644 week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md diff --git a/week-3/Homework/mandatory/2-exercises/1-shopping-cart.js b/week-3/Homework/mandatory/2-exercises/1-shopping-cart.js deleted file mode 100644 index d58a051..0000000 --- a/week-3/Homework/mandatory/2-exercises/1-shopping-cart.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - -Complete the rest of this code to create an online shopping cart. - -The output of running your code should be: - - Your shopping cart has 3 items: Toilet Roll, Pasta, Eggs - - -*/ - -class ShoppingCart { - // Add your code here - - cartContains() { - // Use console.log() to output everything contained in your cart - } -} - -let myCart = new ShoppingCart(); // Creates an empty shopping cart - -myCart.addItem("Toilet Roll"); -myCart.addItem("Pasta"); -myCart.addItem("Eggs"); - -myCart.cartContains(); diff --git a/week-3/Homework/mandatory/2-exercises/2-convertion.js b/week-3/Homework/mandatory/2-exercises/2-convertion.js deleted file mode 100644 index 4c338c9..0000000 --- a/week-3/Homework/mandatory/2-exercises/2-convertion.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - Convert the Function here into a JavaScript Class called 'Person' - - ``` - function createNewPerson(name) { - const obj = {}; - obj.name = name; - obj.greeting = function() { - alert('Hi! I\'m ' + obj.name + '.'); - }; - return obj; - } - - const simon = createNewPerson('simon'); - simon.name; - simon.greeting() - ``` - - When you run this code using `node 2-convertion.js` you should be able to - - -*/ - -// Write your code here - -// Do not edit this section -const simon = new Person("simon"); -console.log(simon.name); -simon.greeting(); -// Do not edit this section diff --git a/week-3/Homework/mandatory/2-exercises/3-atm.js b/week-3/Homework/mandatory/2-exercises/3-atm.js deleted file mode 100644 index 768bce4..0000000 --- a/week-3/Homework/mandatory/2-exercises/3-atm.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - - Create a simple ATM machine. - - Your ATM should allow you to: - - Deposit money - - Withdraw money - - Check your balance. - - You should start with a balance of 100.0 pounds in your account. - - */ - -class ATM { - // Add your code here - -} - -let atm = new ATM(); // Create the ATM - -atm.make_deposit(200); -atm.check_balance(); -atm.make_withdrawl(100); - -atm.make_withdrawl(500); // Your ATM should be able to handle this scenario \ No newline at end of file diff --git a/week-3/Homework/mandatory/2-exercises/4-music-player.js b/week-3/Homework/mandatory/2-exercises/4-music-player.js deleted file mode 100644 index 17f4a2d..0000000 --- a/week-3/Homework/mandatory/2-exercises/4-music-player.js +++ /dev/null @@ -1,50 +0,0 @@ -class MusicPlayer { - // Add your code here - -} - -let myMusicPlayer = new MusicPlayer(); // Create an empty playlist - -// Add some songs to your playlist -myMusicPlayer.add("Bohemian Rhapsody","Queen"); -myMusicPlayer.add("Yesterday","The Beatles"); -myMusicPlayer.add("Vogue","Madonna"); - -myMusicPlayer.play(); // Output: "Currently playing: Bohemian Rhapsody by Queen" - -myMusicPlayer.skip(); // Output: "Currently playing: Yesterday by The Beatles" - -myMusicPlayer.previous(); // Output: "Currently playing: Bohemian Rhapsody by Queen" - -myMusicPlayer.skip(); // Output: "Currently playing: Yesterday by The Beatles" - -myMusicPlayer.skip(); // Output: "Currently playing: Vogue by Madonna" - - -/* - - -Task 1: Complete the above code to create a music player that will run through a playlist of songs and output to the console as described in the comments. - -Task 2: Add some extra logic to handle these 2 scenarios: -- Trying to call myMusicPlayer.play() if there are no songs in the playlist -- Trying to call myMusicPlayer.skip() when there are no songs left to play - - - -Optional 1: Your music player stops once you have reached the end of the playlist. -Can you implement the 'repeat' functionality so that it starts again from the beginning instead of stopping? - - -Optional 2: Can you implement the shuffle functionality for your music player? -This means the order the songs are played in will be random, but each song will only play once. - - */ - - - - - - - - diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js new file mode 100644 index 0000000..10b93ba --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.js @@ -0,0 +1,11 @@ +const personOne = { + name: 'Popeye', + age: 34, + favouriteFood: 'Spinach' +} + +function introduceYourself(___________________________) { + console.log (`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`); +} + +introduceYourself(personOne); \ No newline at end of file diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md new file mode 100644 index 0000000..14462d9 --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md @@ -0,0 +1,20 @@ +Did you know that destructuring can also be used on objects as well. + +We can use destructuring to extract values from an object and assign them to variables in one line. + +``` +let person = { + firstName: "Bruce", + lastName: "Wayne" +} + +let { firstName, lastName} = person; + +console.log(`Batman is ${firstName}, ${lastName}`); +``` + +The program above will print `Batman is Bruce Wayne`. Notice how we use the `{}` characters since it is an object rather than `[]` which is used when it is an array. + +# Exercise +- What is the syntax to destructure the object `personOne` in exercise-1.js? +- Update the argument of the function `introduceYourself` to use destructuring on the object that gets passed in. diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js new file mode 100644 index 0000000..2782172 --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js @@ -0,0 +1,12 @@ +let hogwarts = [ + ['Harry', 'Potter', 'Gryffindor', 'Owl', 'Student'], + ['Hermione', 'Granger', 'Gryffindor', 'Cat', 'Student'], + ['Draco', 'Malfoy', 'Slytherin', 'None', 'Student'], + ['Cedric', 'Diggory', 'HufflePuff', 'None', 'Student'], + ['Severus', 'Snape', 'Slytherin', 'None', 'Teacher'], + ['Filius', 'Flitwick', 'Ravenclaw', 'None', 'Teacher'], + ['Pomona', 'Sprout', 'Hufflepuff', 'None', 'Teacher'], + ['Minerva', 'McGonagall', 'Gryffindor', 'None', 'Teacher'], + ['Albus', 'Dumbledore', 'Gryffindor', 'Phoenix', 'Teacher'] +] + diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md new file mode 100644 index 0000000..be259ca --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md @@ -0,0 +1,32 @@ + +In `exercise-2.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. +For each character you have the following information: +- First Name +- Last Name +- School House +- Pet +- Occupation + + +# Exercise 1 +- In `exercise-2.js` write a program that will display the names of the people who belong to the Gryffindor house. +- Use array destructuring to extract the values you need out of the array. + +## Expected result +``` +Harry Potter +Ron Weasley +Hermione Granger +Minerva McGonagall +Albus Dumbledore +``` + + +# Exercise 2 +- In `exercise-2.js` write a program that will display the names of teachers who have pets. +- Use array destructuring to extract the values you need out of the array. + +## Expected result +``` +Albus Dumbledore +``` diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js new file mode 100644 index 0000000..709adee --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js @@ -0,0 +1,11 @@ + let order = [ + ['Hot cakes', 1, 2.29], + ['Apple Pie', 2, 1.39], + ['Egg McMuffin', 1, 2.80], + ['Sausage McMuffin', 1, 3.00], + ['Hot Coffee', 2, 1.00], + ['Hash Brown', 4, 0.40] + ] + + // Write your code below + \ No newline at end of file diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md new file mode 100644 index 0000000..b1a92a4 --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md @@ -0,0 +1,18 @@ +# Exercise +- In `exercise-3.js`, you have been provided with a takeout order. Write a program that will print out the receipt for this order. +- Use array destructuring to extract the values you need from the order +- Log each individual item to the console. +- Log the total cost of the order to the console. + +## Expected result +``` +QTY ITEM TOTAL +1 Hot Cakes 2.29 +2 Apple Pie 2.78 +1 Egg McMuffin 2.80 +1 Sausage McMuffin 3.00 +2 Hot Coffee 2.00 +4 Hash Brown 1.60 + +Total: 14.47 +``` From 8339225b62bb23d5e54a685052379974a025574c Mon Sep 17 00:00:00 2001 From: Chris Owen Date: Tue, 18 Aug 2020 15:46:04 +0100 Subject: [PATCH 02/10] MD fixes --- .../mandatory/2-exercises/exercise-1/exercise-1.md | 1 + .../mandatory/2-exercises/exercise-2/exercise-2.md | 10 ++++++---- .../mandatory/2-exercises/exercise-3/exercise-3.md | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md index 14462d9..4c2e92d 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md @@ -16,5 +16,6 @@ console.log(`Batman is ${firstName}, ${lastName}`); The program above will print `Batman is Bruce Wayne`. Notice how we use the `{}` characters since it is an object rather than `[]` which is used when it is an array. # Exercise + - What is the syntax to destructure the object `personOne` in exercise-1.js? - Update the argument of the function `introduceYourself` to use destructuring on the object that gets passed in. diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md index be259ca..5b1f91e 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md @@ -1,18 +1,19 @@ - -In `exercise-2.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. +In `exercise-2.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. For each character you have the following information: + - First Name - Last Name - School House - Pet - Occupation - # Exercise 1 + - In `exercise-2.js` write a program that will display the names of the people who belong to the Gryffindor house. - Use array destructuring to extract the values you need out of the array. ## Expected result + ``` Harry Potter Ron Weasley @@ -21,12 +22,13 @@ Minerva McGonagall Albus Dumbledore ``` - # Exercise 2 + - In `exercise-2.js` write a program that will display the names of teachers who have pets. - Use array destructuring to extract the values you need out of the array. ## Expected result + ``` Albus Dumbledore ``` diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md index b1a92a4..531ec4c 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md @@ -1,16 +1,18 @@ # Exercise + - In `exercise-3.js`, you have been provided with a takeout order. Write a program that will print out the receipt for this order. - Use array destructuring to extract the values you need from the order - Log each individual item to the console. - Log the total cost of the order to the console. ## Expected result + ``` QTY ITEM TOTAL 1 Hot Cakes 2.29 2 Apple Pie 2.78 1 Egg McMuffin 2.80 -1 Sausage McMuffin 3.00 +1 Sausage McMuffin 3.00 2 Hot Coffee 2.00 4 Hash Brown 1.60 From e7d060c052f46e34a51ef5ec8fb0447ed7f05d69 Mon Sep 17 00:00:00 2001 From: Chris Owen Date: Tue, 18 Aug 2020 15:48:53 +0100 Subject: [PATCH 03/10] More tweaks --- .../mandatory/2-exercises/exercise-2/exercise-2.md | 12 ++++++++---- .../mandatory/2-exercises/exercise-3/exercise-3.md | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md index 5b1f91e..059d3d4 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md @@ -1,3 +1,7 @@ +# Exercise 2 + +_Need some help? Refresh your memory with [this article](https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/)_ + In `exercise-2.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. For each character you have the following information: @@ -7,12 +11,12 @@ For each character you have the following information: - Pet - Occupation -# Exercise 1 +## Task 1 - In `exercise-2.js` write a program that will display the names of the people who belong to the Gryffindor house. - Use array destructuring to extract the values you need out of the array. -## Expected result +### Expected result ``` Harry Potter @@ -22,12 +26,12 @@ Minerva McGonagall Albus Dumbledore ``` -# Exercise 2 +## Task 2 - In `exercise-2.js` write a program that will display the names of teachers who have pets. - Use array destructuring to extract the values you need out of the array. -## Expected result +### Expected result ``` Albus Dumbledore diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md index 531ec4c..8a007d5 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md @@ -1,5 +1,7 @@ # Exercise +_Need some help? Refresh your memory with [this article](https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/)_ + - In `exercise-3.js`, you have been provided with a takeout order. Write a program that will print out the receipt for this order. - Use array destructuring to extract the values you need from the order - Log each individual item to the console. From c81e3fe9a7ac5ace9c5c42285b4b05cd47ce479d Mon Sep 17 00:00:00 2001 From: Chris Owen Date: Tue, 18 Aug 2020 16:03:53 +0100 Subject: [PATCH 04/10] Create resources.md --- week-3/Homework/mandatory/2-exercises/resources.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 week-3/Homework/mandatory/2-exercises/resources.md diff --git a/week-3/Homework/mandatory/2-exercises/resources.md b/week-3/Homework/mandatory/2-exercises/resources.md new file mode 100644 index 0000000..77e1778 --- /dev/null +++ b/week-3/Homework/mandatory/2-exercises/resources.md @@ -0,0 +1,6 @@ +# Resources + +Here are some useful resources to help you understand this homework + +- [FreeCodeCamp's Intro To Array Destructuring](https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/) +- [Why Is Array/Object Destructuring So Useful And How To Use It](https://www.youtube.com/watch?v=NIq3qLaHCIs) From f683bf2a3fdca5a7a34be836c2efce3eee1b5cb7 Mon Sep 17 00:00:00 2001 From: Chris Owen Date: Tue, 18 Aug 2020 16:04:09 +0100 Subject: [PATCH 05/10] Update resources.md --- week-3/Homework/mandatory/2-exercises/resources.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/week-3/Homework/mandatory/2-exercises/resources.md b/week-3/Homework/mandatory/2-exercises/resources.md index 77e1778..169a6a4 100644 --- a/week-3/Homework/mandatory/2-exercises/resources.md +++ b/week-3/Homework/mandatory/2-exercises/resources.md @@ -3,4 +3,5 @@ Here are some useful resources to help you understand this homework - [FreeCodeCamp's Intro To Array Destructuring](https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/) -- [Why Is Array/Object Destructuring So Useful And How To Use It](https://www.youtube.com/watch?v=NIq3qLaHCIs) +- [Why Is Array/Object Destructuring So Useful And How To Use It (Video)](https://www.youtube.com/watch?v=NIq3qLaHCIs) +- [The Most In-Depth Yet Understandable ES6 Destructuring Tutorial](https://untangled.io/in-depth-es6-destructuring-with-assembled-avengers) From 558e0a82d9260d9aa0b878e343cf1dc08afc5815 Mon Sep 17 00:00:00 2001 From: Louise Chow Date: Sun, 23 Aug 2020 11:30:41 +0100 Subject: [PATCH 06/10] Update the array data provided in the exercises to contain objects --- .../2-exercises/exercise-1/exercise-1.md | 2 +- .../2-exercises/exercise-2/exercise-2.js | 19 +++++++++---------- .../2-exercises/exercise-2/exercise-2.md | 4 ++-- .../2-exercises/exercise-3/exercise-3.js | 14 ++++++-------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md index 4c2e92d..9c3ac97 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-1/exercise-1.md @@ -8,7 +8,7 @@ let person = { lastName: "Wayne" } -let { firstName, lastName} = person; +let { firstName, lastName } = person; console.log(`Batman is ${firstName}, ${lastName}`); ``` diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js index 2782172..0d3ade0 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.js @@ -1,12 +1,11 @@ let hogwarts = [ - ['Harry', 'Potter', 'Gryffindor', 'Owl', 'Student'], - ['Hermione', 'Granger', 'Gryffindor', 'Cat', 'Student'], - ['Draco', 'Malfoy', 'Slytherin', 'None', 'Student'], - ['Cedric', 'Diggory', 'HufflePuff', 'None', 'Student'], - ['Severus', 'Snape', 'Slytherin', 'None', 'Teacher'], - ['Filius', 'Flitwick', 'Ravenclaw', 'None', 'Teacher'], - ['Pomona', 'Sprout', 'Hufflepuff', 'None', 'Teacher'], - ['Minerva', 'McGonagall', 'Gryffindor', 'None', 'Teacher'], - ['Albus', 'Dumbledore', 'Gryffindor', 'Phoenix', 'Teacher'] + { firstName: "Harry", lastName: "Potter", house: "Gryffindor", pet: "Owl", occupation: "Student" }, + { firstName: "Hermione", lastName: "Granger", house: "Gryffindor", pet: "Cat", occupation: "Student" }, + { firstName: "Draco", lastName: "Malfoy", house: "Slytherin", pet: null, occupation: "Student" }, + { firstName: "Cedric", lastName: "Diggory", house: "HufflePuff", pet: null, occupation: "Student" }, + { firstName: "Severus", lastName: "Snape", house: "Slytherin", pet: null, occupation: "Teacher" }, + { firstName: "Filius", lastName: "Flitwick", house: "Ravenclaw", pet: null, occupation: "Teacher" }, + { firstName: "Pomona", lastName: "Sprout", house: "Hufflepuff", pet: null, occupation: "Teacher" }, + { firstName: "Minerva", lastName: "McGonagall", house: "Gryffindor", pet: null, occupation: "Teacher" }, + { firstName: "Albus", lastName: "Dumbledore", house: "Gryffindor", pet: "Phoenix", occupation: "Teacher" } ] - diff --git a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md index 059d3d4..12b8948 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-2/exercise-2.md @@ -13,7 +13,7 @@ For each character you have the following information: ## Task 1 -- In `exercise-2.js` write a program that will display the names of the people who belong to the Gryffindor house. +- In `exercise-2.js` write a program that will take the `hogwarts` array as input and display the names of the people who belong to the Gryffindor house. - Use array destructuring to extract the values you need out of the array. ### Expected result @@ -28,7 +28,7 @@ Albus Dumbledore ## Task 2 -- In `exercise-2.js` write a program that will display the names of teachers who have pets. +- In `exercise-2.js` write a program that will take the `hogwarts` array as input and display the names of teachers who have pets. - Use array destructuring to extract the values you need out of the array. ### Expected result diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js index 709adee..b60d527 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.js @@ -1,11 +1,9 @@ let order = [ - ['Hot cakes', 1, 2.29], - ['Apple Pie', 2, 1.39], - ['Egg McMuffin', 1, 2.80], - ['Sausage McMuffin', 1, 3.00], - ['Hot Coffee', 2, 1.00], - ['Hash Brown', 4, 0.40] + { itemName: "Hot cakes", quantity: 1, unitPrice: 2.29}, + { itemName: "Apple Pie", quantity: 2, unitPrice: 1.39}, + { itemName: "Egg McMuffin", quantity: 1, unitPrice: 2.80}, + { itemName: "Sausage McMuffin", quantity: 1, unitPrice: 3.00}, + { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.00}, + { itemName: "Hash Brown", quantity: 4, unitPrice: 0.40} ] - - // Write your code below \ No newline at end of file From 405bbc2c8135d72beddb87d07fae7d682f37f8a8 Mon Sep 17 00:00:00 2001 From: Louise Chow Date: Sun, 23 Aug 2020 11:39:14 +0100 Subject: [PATCH 07/10] Remove line mentioning array destructuring as the student will use object destructuring instead --- week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md | 1 - 1 file changed, 1 deletion(-) diff --git a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md index 8a007d5..e729ef2 100644 --- a/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md +++ b/week-3/Homework/mandatory/2-exercises/exercise-3/exercise-3.md @@ -3,7 +3,6 @@ _Need some help? Refresh your memory with [this article](https://www.freecodecamp.org/news/array-destructuring-in-es6-30e398f21d10/)_ - In `exercise-3.js`, you have been provided with a takeout order. Write a program that will print out the receipt for this order. -- Use array destructuring to extract the values you need from the order - Log each individual item to the console. - Log the total cost of the order to the console. From d92a4affe72c8b77cd529ac4a7e91da5f89d404c Mon Sep 17 00:00:00 2001 From: IsmaelMartinez Date: Tue, 29 Sep 2020 22:00:12 +0100 Subject: [PATCH 08/10] Explaining ESLint Updating the md file to explain a wee bit eslint without getting into details. --- .../mandatory/0-thinking-like-a-programmer/task.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/week-1/Homework/mandatory/0-thinking-like-a-programmer/task.md b/week-1/Homework/mandatory/0-thinking-like-a-programmer/task.md index 1c841f8..d2b9f40 100644 --- a/week-1/Homework/mandatory/0-thinking-like-a-programmer/task.md +++ b/week-1/Homework/mandatory/0-thinking-like-a-programmer/task.md @@ -2,7 +2,9 @@ ## 1. Install ESLint -Using ESLint can make debugging a lot easier. If you haven't already you should install it now. +ESLint is what is called an static analysis tool. It checks your code for common mistakes that can impact code quality and styling. + +If you haven't already you should install it now. https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint @@ -12,8 +14,9 @@ During these past weeks you have gotten a taste of what programming is: the vari Thinking like a programmer is very similar to thinking like a construction worker: -You have to build something and it's up to you to know all the necessary tools and techniques to make that happen, and -You have to solve every problem that comes up along the way (such as things that go wrong, knowing how to choose the right tools for the job and striving to achieve the right goal) +* You have to build something and it's up to you to know all the necessary tools and techniques to make that happen, and +* You have to solve every problem that comes up along the way (such as things that go wrong, knowing how to choose the right tools for the job and striving to achieve the right goal) + The second skill, problem solving, is the most important one. If you get good at that, you'll automatically get good at the first. Take a look at the following resources to learn more about problem solving as applied to programming: From 8e9e9509a6263a093aaf84670e5c42be051e1090 Mon Sep 17 00:00:00 2001 From: IsmaelMartinez Date: Tue, 29 Sep 2020 22:02:45 +0100 Subject: [PATCH 09/10] Update task.md Removing rough . in the list --- week-1/Homework/mandatory/1-debugging-practice/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-1/Homework/mandatory/1-debugging-practice/task.md b/week-1/Homework/mandatory/1-debugging-practice/task.md index ccb7c99..d73db65 100644 --- a/week-1/Homework/mandatory/1-debugging-practice/task.md +++ b/week-1/Homework/mandatory/1-debugging-practice/task.md @@ -13,7 +13,7 @@ My website should be able to: 1. Website loads but nothing works in my javascript 2. Website loads but nothing happens 3. Error in console when you try to add a book -4. It uses the title name as the author name. +4. It uses the title name as the author name 5. Delete button is broken 6. When I add a book that I say I've read - it saves the wrong answer From 7d8a14da3638f8e953c73f029f133d0bce4f7dbc Mon Sep 17 00:00:00 2001 From: IsmaelMartinez Date: Fri, 2 Oct 2020 14:06:06 +0100 Subject: [PATCH 10/10] Standarizing function contruct Adding the function f1() to the 1st example/question because it follows the standards better and it might remove confusion. Agree that by doing `{ }` is the same as `function{ }` (so it works), but is just to avoid confusion to the students. --- .../Homework/mandatory/1-practice/2-code-reading.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/week-3/Homework/mandatory/1-practice/2-code-reading.md b/week-3/Homework/mandatory/1-practice/2-code-reading.md index 295964e..72651a2 100644 --- a/week-3/Homework/mandatory/1-practice/2-code-reading.md +++ b/week-3/Homework/mandatory/1-practice/2-code-reading.md @@ -6,11 +6,12 @@ Take a look at the following code: ``` 1 let x = 1; -2 { -3 let x = 2; -4 console.log(x); -5 } -6 console.log(x); +2 function f1() +3 { +4 let x = 2; +5 console.log(x); +6 } +7 console.log(x); ``` Explain why line 4 and line 6 output different numbers.