|
1 |
| -## Homework week 1: |
| 1 | +## Homework Week 1 |
2 | 2 |
|
3 | 3 | ```
|
4 | 4 | Topics discussed in class this week:
|
5 |
| -• Git |
| 5 | +• CLI |
| 6 | +• Intro JavaScript (What is it, where can you use it for) |
| 7 | +• Variables [var, let, const] |
| 8 | +• Basic Data types [Strings, Numbers, Arrays, Booleans] |
| 9 | +• Operators |
6 | 10 | ```
|
7 | 11 |
|
8 |
| ->[Here](/Week1/README.md) you find the readings you have to complete before the fifth lecture. |
| 12 | +>[Here](/Week1/README.md) you find the readings you have to complete before the second lecture. |
9 | 13 |
|
10 |
| -## Step 1: Share a useful resource |
| 14 | +## Before you start with the homework: |
11 | 15 |
|
12 |
| -_Deadline Monday_ |
| 16 | +1. Go through the review of [week 1](https://github.com/HackYourFuture/JavaScript/blob/master/Week1/REVIEW.md) |
| 17 | +2. 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). |
| 18 | +3. 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): |
| 19 | + <br>0. Introduction |
| 20 | + 1. Programming Basics |
| 21 | + 2. Core Programming Syntax |
| 22 | + 3. Variables and Data Types |
13 | 23 |
|
14 |
| -All share a video or a resource (this can be a drawing, article or a pod cast) that was helpful for you the last few weeks with learning JavaScript. Please share this in the channel of your class in Slack. Also write as small note about what the resource i about and why you think it's so helpful (you can share more than one if you like). |
15 | 24 |
|
16 | 25 | ## Step 2: Feedback
|
17 | 26 |
|
18 |
| -_Deadline Monday_ |
| 27 | +_Deadline Wednesday_ |
19 | 28 |
|
20 |
| -Give one of your fellow students in Github feedback about their homework of the previous week: create an issue in their repo, telling them what they did great and what they can improve. |
| 29 | +Provide feedback on the HTML-CSS assignments (week 3) of one of your fellow students. You will be assigned to one of the assignments by the class lead of this week. |
21 | 30 |
|
22 |
| -Step3 |
| 31 | +## Step 3: JavaScript |
23 | 32 |
|
24 |
| -## Step 3: Git homework |
| 33 | +_Deadline Thursday_ |
25 | 34 |
|
26 |
| -_Deadline Wednesday_ |
| 35 | +> 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. |
| 36 | +
|
| 37 | +1\. Write a `console.log` statement saying "Hello World!" for each language that you know. |
| 38 | + |
| 39 | +For example: |
| 40 | +``` |
| 41 | +Halo, dunia! // Indonesian |
| 42 | +Ciao, mondo! // Italian |
| 43 | +Hola, mundo! // Spanish |
| 44 | +``` |
| 45 | + |
| 46 | +2\. Consider the following code: |
| 47 | +``` |
| 48 | +console.log('I'm awesome'); |
| 49 | +``` |
| 50 | +2\.1 Copy the code in your `.js` file and run it. You will see that you will get a SyntaxError. Find a solution for this error, Hint read the error message carefully, it also gives an indication of where the problem is. |
| 51 | + |
| 52 | +3\. Declare a variable `x` and initialize it with an integer. |
| 53 | +3\.1 First, _declare_ your variable `x`. |
| 54 | +3\.2 Add a console.log statement that explains that explains in words what _you think_ the value of `x` is, like in this example: |
| 55 | +```js |
| 56 | + // TODO -> here you initialize your variable |
| 57 | + console.log('the value of my variable x will be: whateverYouThinkItWillLog'); |
| 58 | +``` |
| 59 | +3\.3 Add a console.log statement that logs the value of `x`. |
| 60 | +3\.4 Now _initialize_ your variable `x` with an integer. |
| 61 | +3\.5 Now add a console.log statement that explains what _you think_ the value of `x` is. |
| 62 | +3\.6 Add a console.log statement that logs the value of `x`. |
| 63 | + Steps to be taken: |
| 64 | + |
| 65 | +```js |
| 66 | + // TODO -> here you declare your variable |
| 67 | + console.log('the value of x will be: whateverYouThinkItWillLog'); |
| 68 | + // TODO -> log the actual value of x |
| 69 | + // TODO -> here you initialize your variable |
| 70 | + console.log('the value of x will be: whateverYouThinkItWillLog'); |
| 71 | + // TODO -> log value of x again |
| 72 | +``` |
27 | 73 |
|
28 |
| -Git homework for this week: |
| 74 | +4\. Declare a variable `y` and assign a string to it. |
| 75 | +4\.1 Write a console.log statement in which you explain in words what _you think_ the value of the string is. |
| 76 | +4\.2 Now console.log the variable `y`. |
| 77 | +4\.3 Now assign a new string to the variable `y`. |
| 78 | +4\.4 Just like you did before write a console.log statement that explains in words what you think will be logged to the console. |
| 79 | +4\.5 Now console.log `y` again. |
| 80 | +```js |
| 81 | + // TODO -> here you declare AND assign your string |
| 82 | + console.log('the value of my string will be: whateverYouThinkItWillLog'); |
| 83 | + // TODO -> log the actual value of the string to the console |
| 84 | + // TODO -> assign a new value to your variable x |
| 85 | + console.log('the value of my string will be: whateverYouThinkItWillLog'); |
| 86 | + // TODO -> log the actual value of the string to the console |
| 87 | +``` |
| 88 | + |
| 89 | +5\. How do you round the number 7.25, to the nearest integer? |
| 90 | +5\.1 Declare a variable `z` and assign the number 7.25 to it. |
| 91 | +5\.2 Console.log `z`. |
| 92 | +5\.3 Declare another variable `a` that has the value of z but rounded to the nearest integer. |
| 93 | +5\.4 Console.log `a`. |
| 94 | +5\.5 So now we have `z` and `a` find a way to compare the two values and store the highest of the two in a new variable. |
| 95 | +5\.6 Console.log the highest value. |
| 96 | + |
| 97 | +6\. *Arrays!* |
| 98 | +6\.1 Declare an empty array. |
| 99 | +6\.2 Write a console.log statement that explains in words what you think the value of the array is. |
| 100 | +6\.3 Console.log your array. |
| 101 | +6\.4 Create an array that has your favorite animals inside (you can decide on how to call it yourself, but read on a bit here and see if you can find a good name that exactly describes what this variable will hold). |
| 102 | +6\.5 Log your array. |
| 103 | +6\.6 Add a statement that adds Daan's favorite animal (baby pig) to the *existing array*. |
| 104 | +6\.7 Log your new array! |
| 105 | + |
| 106 | +7\. *More strings* |
| 107 | +7\.1 Let's consider the following string: `let myString = "this,is,a,test"`. |
| 108 | +7\.2 Add the string to your file and console.log it. |
| 109 | +7\.3 Find a way to get the length of `myString`. |
| 110 | +7\.4 Console.log the length of `myString`. |
| 111 | + |
| 112 | +8\. Write a program that checks the types of two variables and prints out `SAME TYPE` if they are the same type. |
| 113 | +8\.1 First declare at least four variables and assign them different data types. |
| 114 | +8\.2 For each variable write a `console.log` statement that logs the value |
| 115 | + ```js |
| 116 | + let foo = 3; |
| 117 | + console.log('The value of my variable foo is: ' + foo); |
| 118 | + ``` |
| 119 | +8\.3 Now write a console.log statement wherein you first explain in words what you think the _type_ of your variables is. |
| 120 | +8\.4 Now use `typeof` to log the actual _type_ of your variables. |
| 121 | +8\.5 Now compare the types of your different variables with one another. |
| 122 | +8\.6 Make sure to also show a message when the variables you are comparing are not the same type. |
| 123 | + |
| 124 | +For example: |
| 125 | + |
| 126 | +```js |
| 127 | +let x = 9; |
| 128 | +let y = 'Hello'; |
| 129 | + |
| 130 | +if () { |
| 131 | + console.log('SAME TYPE'); |
| 132 | +} |
| 133 | +// TODO -> add a way of giving feedback if your variables don't have the same type |
| 134 | +``` |
| 135 | + |
| 136 | +9\. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the new value of `x`? |
| 137 | +9\.1 Add at least 3 `console.log` statements in which you show that you understand what `%` does. |
| 138 | + |
| 139 | +10\. Write a program to answer the following questions: |
| 140 | +10\.1 Can you store multiple types in an array? Numbers and strings? Make an example that illustrates your answer. |
| 141 | +10\.2 Can you compare infinities? (Not in Eyad's world) - does 6/0 === 10/0? How can you test this? |
| 142 | +10\.3 Add console.log statements to the above program's in which you show that you understand the concepts (just like you've done in the above assignments). |
| 143 | + |
| 144 | +## Step 4: **Some freeCodeCamp challenges (10 hours):** |
29 | 145 |
|
30 |
| -Pair up with another student in your class. The homework requires two people to work together. Let us call them admin and user. |
| 146 | +_Deadline Saturday_ |
31 | 147 |
|
32 |
| -1. admin creates a new repository on github called “animals” (without quotes). |
33 |
| -2. admin adds a file called “zoo.txt” with some animal generally found in a zoo. |
34 |
| -3. admin commits and pushes his changes (in master branch) |
35 |
| -4. admin adds user as a collaborator (find out how to add a collaborator to a git repository) |
36 |
| -5. user clones a repository from admin (find out how to clone a repository. Note that `git init` is not required when you clone a repository) |
37 |
| -6. user makes a new branch called user-dev |
38 |
| -7. user adds another file called “pets.txt” with some animals generally found in a home. |
39 |
| -8. user commits and pushes his branch to remote |
40 |
| -9. admin pulls the branch crated by user (find out how to pull changes from the repository) |
41 |
| -10. admin submits the link to his github repository (named animal), where unmesh should be able to see the collaborator’s (i.e. user’s) branch along with his commits. |
| 148 | +On freeCodeCamp.com please do the [Basic JavaScript](https://www.freecodecamp.com/challenges/learn-how-free-code-camp-works) exercises up and until the __"Shopping List"__ exercise (there are some topics we did not cover but you can do it). |
42 | 149 |
|
43 |
| -Note: |
| 150 | +## Step 5: Read before next lecture |
| 151 | + |
| 152 | +_Deadline Sunday morning_ |
| 153 | + |
| 154 | +Go trough the reading material in the [README.md](/Week1/README.md) to prepare for your next class |
| 155 | + |
| 156 | +### How to hand in Homework: |
| 157 | +``` |
| 158 | +• Create a new repository "hyf-javascript1". Also create a new folder "week1" inside this repository. |
| 159 | +• Upload your homework files inside the week1 folder and write a description for this “commit”. |
| 160 | +• Your hyf-javascript1/week1 should now contain all your homework files. |
| 161 | +• Place the link to your repository folder in Trello. |
| 162 | +``` |
44 | 163 |
|
45 |
| -The *user* is *not supposed to fork* the admin’s repository. *admin* is supposed to add user as a collaborator and *user* should just *clone* the repository (i.e. *user* will only have the local copy of the repository). Only *admin* will have the *github* server copy of the repository. Of course, admin will have its local copy of the repository too. |
| 164 | +### Hint |
| 165 | +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 in a repository 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. |
46 | 166 |
|
| 167 | +:star: Additional resources and review: [here](/Week1/REVIEW.md):star: |
0 commit comments