|
1 |
| -## Assignments week 1: |
| 1 | +## Homework week 1: |
| 2 | + |
| 3 | +>[Here](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/README.md) you find the readings you have to complete before the second lecture. |
2 | 4 |
|
3 | 5 | We covered a bit of command line usage in the first class and got a program running which is great. If you need a refresher for the command line please have a look here: https://github.com/HackYourFuture/CommandLine
|
4 | 6 |
|
5 |
| -### Homework |
| 7 | +## Before you start with the homework: |
6 | 8 |
|
7 |
| -1. Create a `.js` file that prints `Hello` when you run it from the command line. (Hint: `node` is the program that can run your JavaScript files.) |
| 9 | +1. 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). |
| 10 | +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): |
| 11 | + 0. Introduction |
| 12 | + 1. Programming Basics |
| 13 | + 2. Core Programming Syntax |
| 14 | + 3. Variables and Data Types |
8 | 15 |
|
9 |
| -2. Write a program (like we did in class) that checks the types of two varibales and prints out `SAME TYPE` if they are the same type. |
10 |
| -For example: |
11 |
| - ```js |
12 |
| - let x = 9; |
13 |
| - let y = 'Hello'; |
| 16 | +## Step 1: Command Line |
14 | 17 |
|
15 |
| - if () { |
16 |
| - console.log('SAME TYPE'); |
17 |
| - } |
| 18 | +1. Create a `.js` file that prints `Hello` when you run it from the command line. (Hint: `node` is the program that can run your JavaScript files.) |
18 | 19 |
|
19 |
| - ``` |
| 20 | +>2. Write commands to do following: |
| 21 | + 1. create a directory. Enter a directory. Create an empty file named blank. |
| 22 | + 2. Then write the content `"Hello"` five times to the file greetings.txt. |
| 23 | + Then copy the file greetings.txt and paste its contents into 1.txt, 2.txt, 3.txt, 4.txt and 5.txt. |
| 24 | + 3. Then write the text "cat" to pets.txt |
| 25 | + Then append the text "dog" to pets.txt |
| 26 | + Then append the text "hamster" to pets.txt |
| 27 | + 4. Then write the text "cat" to commands.txt |
| 28 | + Then append the text "ls" to commands.txt |
| 29 | + Then append the text "pwd" to commands.txt |
| 30 | + 5. Then find unique strings from these two files pets.txt and commands.txt |
| 31 | + and store the unique strings in lovelyCommands.txt |
20 | 32 |
|
21 |
| -3. Create a function that takes 3 arguments and returns the sum of the three arguments. |
22 | 33 |
|
23 |
| -4. Create a function named `colorCar` that receives a color, and prints out, "a red car" for example. (Hint: put it in your file and run it like before.) |
| 34 | +## Step 2: JavaScript |
24 | 35 |
|
25 |
| -5. Create an object and a function that takes the object as a parameter and prints out all of its names and values. |
| 36 | +> 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 |
26 | 37 |
|
27 |
| -6. 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)` |
| 38 | +1. Declare a variable `x` and initialize it with an integer. |
28 | 39 |
|
29 |
| -7. Create a function called `vehicle`, like before, but takes another parameter called age, so that `vehicle("blue", 1, 5)` prints "a blue used car" |
| 40 | +2. How do you round the number 7.25, to the nearest integer? |
30 | 41 |
|
31 |
| -8. Make a list of vehicles, you can add `"motorbike"`, `"caravan"`, `"bike"`, or more. |
| 42 | +3. Create a array called `colors` with the strings red, green and blue inside. |
32 | 43 |
|
33 |
| -9. How do you get the third element from that list? |
| 44 | +4. How can you find the length of the string you just created? |
34 | 45 |
|
35 |
| -10. Change the function `vehicle` to use the list of question 5. So that `vehicle("green", 3, 1)` prints "a green new caravan". |
| 46 | +5. Write a program that checks the types of two variables and prints out `SAME TYPE` if they are the same type. |
| 47 | +For example: |
| 48 | + ```js |
| 49 | + let x = 9; |
| 50 | + let y = 'Hello'; |
36 | 51 |
|
37 |
| -11. Use the list of vehicles to write an advertisment. So that it prints something like: `"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes."`. (Hint: use a `for` loop.) |
| 52 | + if () { |
| 53 | + console.log('SAME TYPE'); |
| 54 | + } |
38 | 55 |
|
39 |
| -12. What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 8? |
| 56 | + ``` |
| 57 | + |
| 58 | +6. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the new value of `x`? |
40 | 59 |
|
41 |
| -13. Write a program to answer the following questions: |
| 60 | +7. Write a program to answer the following questions: |
42 | 61 | * Can you store multiple types in an array? Numbers and strings?
|
43 | 62 | * Can you compare inifities? (Not in Eyad's world) - does 6/0 == 10/0? How can you test this?
|
44 | 63 |
|
45 |
| -14. Can you write the following without the `if` statement, but with just as a single line with `console.log(...);`? |
46 |
| -```js |
47 |
| -if (3 == 3) { |
48 |
| - console.log("true") |
49 |
| -} else { |
50 |
| - console.log("false") |
51 |
| -} |
52 |
| -``` |
53 |
| - |
| 64 | +### Step 3: **Some freeCodeCamp challenges (10 hours):** |
54 | 65 |
|
55 |
| -On freecodecamp.com please try to do all [Basic JavaScript](https://www.freecodecamp.com/challenges/learn-how-free-code-camp-works) exercises (there are some topics we did not cover but you can do it). Please make sure you REALLY understand the exercises below: |
| 66 | +On freeCodeCamp.com please do all [Basic JavaScript](https://www.freecodecamp.com/challenges/learn-how-free-code-camp-works) exercises (there are some topics we did not cover but you can do it). Please make sure you REALLY understand the exercises below: |
56 | 67 |
|
57 | 68 | - https://www.freecodecamp.com/challenges/multiply-two-decimals-with-javascript
|
58 | 69 | - https://www.freecodecamp.com/challenges/store-multiple-values-in-one-variable-using-javascript-arrays
|
59 | 70 | - https://www.freecodecamp.com/challenges/build-javascript-objects
|
60 | 71 | - https://www.freecodecamp.com/challenges/add-new-properties-to-a-javascript-object
|
61 | 72 | - https://www.freecodecamp.com/challenges/delete-properties-from-a-javascript-object
|
62 | 73 |
|
| 74 | +> Hint, if you solve the FreeCodeCamp challenges and they are new concepts to you and you would like to take a look at them later on in the program, Copy your answers from FCC in a .js file and upload them to Github for future reference. In this way you build your own little documentation, if you look back at them first try to understand what it does before you run them. |
| 75 | +
|
| 76 | +Additional resources and review: [here](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/REVIEW.md) (work in progress) |
| 77 | + |
0 commit comments