From 73b5fa4ba9659022da371887315f1c61b58150a7 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 17:43:38 +0100 Subject: [PATCH 1/8] :art: style: Clean whitespaces --- Week3/MAKEME.md | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 70f60b71c..977c56884 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -36,41 +36,41 @@ Provide feedback to the homework of last week to one of your fellow students. Yo - [Loops (for/while)](../fundamentals/loops.md) - [Functions](../fundamentals/functions.md) - [Scope](../fundamentals/scope.md) - + ## Step 2: Watch -1. If you haven't done already, watch: [What is programming](https://www.khanacademy.org/computing/computer-programming/programming/intro-to-programming/v/programming-intro) +1. If you haven't done already, watch: [What is programming](https://www.khanacademy.org/computing/computer-programming/programming/intro-to-programming/v/programming-intro) Just watch the 2 min video, you do not have to do the entire JavaScript course (It could be useful later on though). -2. Please watch the following parts of the course, [Programming Foundations Fundamentals](https://www.lynda.com/Programming-Foundations-tutorials/Welcome/83603/90426-4.html) on Lynda.com (if you don't have access to Lynda yet ask Gijs): +2. Please watch the following parts of the course, [Programming Foundations Fundamentals](https://www.lynda.com/Programming-Foundations-tutorials/Welcome/83603/90426-4.html) on Lynda.com (if you don't have access to Lynda yet ask Gijs):
**4. Writing Conditional Code**
**5. Modular Code**
**6. Iteration: Writing Loops**
**7. More About Strings**
**8. Collections** -
**11. When Things Go Wrong** +
**11. When Things Go Wrong** -## Step 3: Rover the Robot +## Step 3: Rover the Robot -Go and try out this cool game: [roverjs.com](http://roverjs.com), written by one of our HYF teachers, Joost Lubach. There are different levels, see how far you can get! +Go and try out this cool game: [roverjs.com](http://roverjs.com), written by one of our HYF teachers, Joost Lubach. There are different levels, see how far you can get! ## Step 4: String and Array challenges -_Deadline Wednesday_ +_Deadline Wednesday_ > For all the following exercises create a new .js file. Try to find a proper name for each file or make a small comment about what it does inside for future reference *IMPORTANT NOTE* In each assignment write at least two `console.log` statements to verify if your code works correctly. In other words proof that you code works as expected. If you need inspiration look at the steps defined in the assignments from last week. -1\. **Strings!** -1\.1 Let's consider the following string: `let myString = "hello,this,is,a,difficult,to,read,sentence"` -1\.2 Add the string to your file and console.log it. -1\.4 Console.log the length of `myString`. -1\.5 The commas make that the sentence is quite hard to read. Find a way to remove the comma's from the sting and replace them with a spaces -1\.6 Console.log `myString` to see if you succeeded. +1\. **Strings!** +1\.1 Let's consider the following string: `let myString = "hello,this,is,a,difficult,to,read,sentence"` +1\.2 Add the string to your file and console.log it. +1\.4 Console.log the length of `myString`. +1\.5 The commas make that the sentence is quite hard to read. Find a way to remove the comma's from the sting and replace them with a spaces +1\.6 Console.log `myString` to see if you succeeded. -2\. **Arrays!** +2\. **Arrays!** Consider the following array: @@ -78,15 +78,15 @@ Consider the following array: let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; ``` -2\.1 Add a statement that adds Mauro's favorite animal ('turtle') to the existing array -2\.2 Log your new array! -2\.3 Now add Jim's favorite animal to the array, its a 'meerkat', but make sure it will be placed after 'blowfish' and before 'capricorn'. -2\.4 Write a console.log statement that explains in words _you think_ the new value of the array is. -2\.5 Log your new new array! -2\.6 Log the length of the array, add a message: "The array has a length of: "(here you should show the length of the array) -2\.7 Jason does not like giraffes, delete this animal from the array -2\.8 Again log your new array. -2\.9 Now if unlike Jim, you don't like meerkats and you want to delete it from the array, but you don't know the position or the `index` of the item in the array, how can you find it? +2\.1 Add a statement that adds Mauro's favorite animal ('turtle') to the existing array +2\.2 Log your new array! +2\.3 Now add Jim's favorite animal to the array, its a 'meerkat', but make sure it will be placed after 'blowfish' and before 'capricorn'. +2\.4 Write a console.log statement that explains in words _you think_ the new value of the array is. +2\.5 Log your new new array! +2\.6 Log the length of the array, add a message: "The array has a length of: "(here you should show the length of the array) +2\.7 Jason does not like giraffes, delete this animal from the array +2\.8 Again log your new array. +2\.9 Now if unlike Jim, you don't like meerkats and you want to delete it from the array, but you don't know the position or the `index` of the item in the array, how can you find it? 2\.10 Log the index of meerkat to the console. Add a message so it says: "The item you are looking for is at index: " (here you should show the index of the item) ## More JavaScript :tada: @@ -130,7 +130,7 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; 14. Add a property to the object you just created that contains the languages that they have taught you. 15. Write some code to test two arrays for equality using `==` and `===`. Test the following: - + ```js let x = [1,2,3]; let y = [1,2,3]; @@ -138,16 +138,16 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; ``` What do you think will happen with `x == y`, `x === y` and `z == y` and `z == x`? Prove it! - + > Don't cheat! Seriously - try it first. - + Check out this [Fiddle](http://jsfiddle.net/jimschubert/85M4z/). You need to open your browser’s Developer Tools to see the console output. Press the Run button in the upper right corner to run the code. More insights from this [Stack Overflow question](http://stackoverflow.com/questions/22395357/how-to-compare-two-arrays-are-equal-using-javascript). -16. Take a look at the following code: +16. Take a look at the following code: ```js let o1 = { foo: 'bar' }; @@ -156,19 +156,19 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; ``` - Show that changing `o2` changes `o3` (or not) and changing `o1` changes `o3`(or not). - + Show that changing `o2` changes `o3` (or not) and changing `o1` changes `o3`(or not). + Does the order that you assign (`o3 = o2` or `o2 = o3`) matter? 17. What does the following code return? (And why?) ```js - let bar = 42; + let bar = 42; typeof typeof bar; ``` - -> ‘Coerce' means to try to change - so coercing `var x = '6'` to number means trying to change the type to number temporarily. + +> ‘Coerce' means to try to change - so coercing `var x = '6'` to number means trying to change the type to number temporarily. ## Step 7: **Finish basic freeCodeCamp challenges:** @@ -191,7 +191,7 @@ Go through the reading material in the [README.md](/Week2/README.md) to prepare ``` How to hand in your homework: -• Upload your homework in your "hyf-javascript1" Github repository. Make sure to create a new folder "week2" first. +• Upload your homework in your "hyf-javascript1" Github repository. Make sure to create a new folder "week2" first. • Upload your homework files inside the week2 folder and write a description for this “commit”. • Your hyf-javascript1/week2 should now contain all your homework files. • Place the link to your repository folder in Trello. From 820c7ef170e21a810139df5dc12d8a9bff37c018 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:05:58 +0100 Subject: [PATCH 2/8] :pencil: fix: Spelling and grammar corrections --- Week3/MAKEME.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 977c56884..2ea599a03 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -64,10 +64,10 @@ _Deadline Wednesday_ In each assignment write at least two `console.log` statements to verify if your code works correctly. In other words proof that you code works as expected. If you need inspiration look at the steps defined in the assignments from last week. 1\. **Strings!** -1\.1 Let's consider the following string: `let myString = "hello,this,is,a,difficult,to,read,sentence"` +1\.1 Let's consider the following string: `let myString = "hello,this,is,a,difficult,to,read,sentence"`. 1\.2 Add the string to your file and console.log it. 1\.4 Console.log the length of `myString`. -1\.5 The commas make that the sentence is quite hard to read. Find a way to remove the comma's from the sting and replace them with a spaces +1\.5 The commas make that the sentence is quite hard to read. Find a way to remove the commas from the string and replace them with spaces. 1\.6 Console.log `myString` to see if you succeeded. 2\. **Arrays!** @@ -80,9 +80,9 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; 2\.1 Add a statement that adds Mauro's favorite animal ('turtle') to the existing array 2\.2 Log your new array! -2\.3 Now add Jim's favorite animal to the array, its a 'meerkat', but make sure it will be placed after 'blowfish' and before 'capricorn'. +2\.3 Now add Jim's favorite animal to the array, it's a 'meerkat', but make sure it will be placed after 'blowfish' and before 'capricorn'. 2\.4 Write a console.log statement that explains in words _you think_ the new value of the array is. -2\.5 Log your new new array! +2\.5 Log your new array! 2\.6 Log the length of the array, add a message: "The array has a length of: "(here you should show the length of the array) 2\.7 Jason does not like giraffes, delete this animal from the array 2\.8 Again log your new array. From 3044904d3dbf2f4968cca48d58a804464304b573 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:26:31 +0100 Subject: [PATCH 3/8] :star2: refactor: Take out string initialization out of the challenges --- Week3/MAKEME.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 2ea599a03..113fcf30e 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -64,11 +64,17 @@ _Deadline Wednesday_ In each assignment write at least two `console.log` statements to verify if your code works correctly. In other words proof that you code works as expected. If you need inspiration look at the steps defined in the assignments from last week. 1\. **Strings!** -1\.1 Let's consider the following string: `let myString = "hello,this,is,a,difficult,to,read,sentence"`. -1\.2 Add the string to your file and console.log it. -1\.4 Console.log the length of `myString`. -1\.5 The commas make that the sentence is quite hard to read. Find a way to remove the commas from the string and replace them with spaces. -1\.6 Console.log `myString` to see if you succeeded. + +Consider the following string: + +```js +let myString = "hello,this,is,a,difficult,to,read,sentence"; +``` + +1\.1 Add the string to your file and console.log it. +1\.2 Console.log the length of `myString`. +1\.3 The commas make that the sentence is quite hard to read. Find a way to remove the commas from the string and replace them with spaces. +1\.4 Console.log `myString` to see if you succeeded. 2\. **Arrays!** From 35af4c2baac325a7731ce5dc54aeef1bc1141896 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:38:14 +0100 Subject: [PATCH 4/8] :pencil2: refactor: Replace `console.log` with log verb --- Week3/MAKEME.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 113fcf30e..f028a0438 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -71,10 +71,10 @@ Consider the following string: let myString = "hello,this,is,a,difficult,to,read,sentence"; ``` -1\.1 Add the string to your file and console.log it. -1\.2 Console.log the length of `myString`. +1\.1 Add the string to your file and log it. +1\.2 Log the length of `myString`. 1\.3 The commas make that the sentence is quite hard to read. Find a way to remove the commas from the string and replace them with spaces. -1\.4 Console.log `myString` to see if you succeeded. +1\.4 Log `myString` to see if you succeeded. 2\. **Arrays!** From 2cc49f528333cdd0fcf045a5e623ecc306ade5ed Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:44:51 +0100 Subject: [PATCH 5/8] :bulb: refactor: Use yes/no to ensure using conditional operator --- Week3/MAKEME.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index f028a0438..4e76ecde4 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -109,9 +109,9 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; ```js if (3 === 3) { - console.log("true") + console.log("yes") } else { - console.log("false") + console.log("no") } ``` From e7b7fea113b3fda991d4e464cbba88279180e1b4 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:53:29 +0100 Subject: [PATCH 6/8] :bug: fix: According to `vehiclesList` the 3rd (ordinary) is bike --- Week3/MAKEME.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 4e76ecde4..92f609735 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -121,7 +121,7 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; 8. How do you get the third element from that list? -9. Change the function `vehicle` to use the list of question 7. So that `vehicle("green", 3, 1)` prints "a green new caravan". +9. Change the function `vehicle` to use the list of question 7. So that `vehicle("green", 3, 1)` prints "a green new bike". 10. Use the list of vehicles to write an advertisement. So that it prints something like: `"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes."`. (Hint: use a `for` loop.) From e6abfb576d684bb5c52b46cf8019211119694c5e Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 18:57:56 +0100 Subject: [PATCH 7/8] :bulb: refactor: Ask to print properties to avoid confusion --- Week3/MAKEME.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 92f609735..22e733f96 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -101,7 +101,7 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; 2. Create a function named `colorCar` that receives a color, and prints out, "a red car" for example. -3. Create an object and a function that takes the object as a parameter and prints out all of its names and values. +3. Create an object and a function that takes the object as a parameter and prints out all of its properties and values. 4. Create a function named `vehicleType` that receives a color, and a code, 1 for car, 2 for motorbike. And prints "a blue motorbike" for example when called as `vehicleType("blue", 2)` From 2007189949d9c02cc787a312383fc3373165bf43 Mon Sep 17 00:00:00 2001 From: Samir Aleido Date: Sat, 24 Feb 2018 19:08:16 +0100 Subject: [PATCH 8/8] :art: style: Consistent format across all changes --- Week3/MAKEME.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Week3/MAKEME.md b/Week3/MAKEME.md index 22e733f96..2ea951464 100644 --- a/Week3/MAKEME.md +++ b/Week3/MAKEME.md @@ -84,26 +84,26 @@ Consider the following array: let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; ``` -2\.1 Add a statement that adds Mauro's favorite animal ('turtle') to the existing array +2\.1 Add a statement that adds Mauro's favorite animal *'turtle'* to the existing array. 2\.2 Log your new array! -2\.3 Now add Jim's favorite animal to the array, it's a 'meerkat', but make sure it will be placed after 'blowfish' and before 'capricorn'. +2\.3 Now add Jim's favorite animal to the array, it's *'meerkat'*, but make sure it will be placed after *'blowfish'* and before *'capricorn'*. 2\.4 Write a console.log statement that explains in words _you think_ the new value of the array is. 2\.5 Log your new array! -2\.6 Log the length of the array, add a message: "The array has a length of: "(here you should show the length of the array) -2\.7 Jason does not like giraffes, delete this animal from the array +2\.6 Log the length of the array, add a message: *'The array has a length of: '* (here you should show the length of the array). +2\.7 Jason does not like *'giraffe'*, delete this animal from the array. 2\.8 Again log your new array. -2\.9 Now if unlike Jim, you don't like meerkats and you want to delete it from the array, but you don't know the position or the `index` of the item in the array, how can you find it? -2\.10 Log the index of meerkat to the console. Add a message so it says: "The item you are looking for is at index: " (here you should show the index of the item) +2\.9 Now if unlike Jim, you don't like *'meerkat'* and you want to delete it from the array, but you don't know the position or the `index` of the item in the array, how can you find it? +2\.10 Log the index of *'meerkat'*. Add a message so it says: *'The item you are looking for is at index: '* (here you should show the index of the item). ## More JavaScript :tada: -1. Create a function that takes 3 arguments and returns the sum of the three arguments. +1. Create a function that takes 3 arguments and returns the sum of the these arguments. -2. Create a function named `colorCar` that receives a color, and prints out, "a red car" for example. +2. Create a function named `colorCar` that receives a color, and prints out, *'a red car'* for example. 3. Create an object and a function that takes the object as a parameter and prints out all of its properties and values. -4. Create a function named `vehicleType` that receives a color, and a code, 1 for car, 2 for motorbike. And prints "a blue motorbike" for example when called as `vehicleType("blue", 2)` +4. Create a function named `vehicleType` that receives a color, and a code, 1 for car, 2 for motorbike. And prints *'a blue motorbike'* for example when called as `vehicleType("blue", 2)` 5. Can you write the following without the `if` statement, but with just as a single line with `console.log(...);`? @@ -115,7 +115,7 @@ let favoriteAnimals = ['blowfish', 'capricorn', 'giraffe']; } ``` -6. Create a function called `vehicle`, like before, but takes another parameter called age, so that `vehicle("blue", 1, 5)` prints "a blue used car" +6. Create a function called `vehicle`, like before, but takes another parameter called `age`, so that `vehicle("blue", 1, 5)` prints *'a blue used car'* 7. Make a list of vehicles, you can add `"motorbike"`, `"caravan"`, `"bike"`, or more.