You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite the above program using `map` and `filter` don't forget to use `=>`.
43
+
Rewrite the above `doubleOddNumbers` function using `map` and `filter`; don't forget to use `=>`.
43
44
44
45
---
45
46
@@ -87,8 +88,6 @@ const tuesday = [
87
88
duration:40
88
89
}
89
90
];
90
-
91
-
consttasks=monday.concat(tuesday);
92
91
```
93
92
94
93
_Note: the durations are specified in minutes._
@@ -99,16 +98,70 @@ Follow these steps. Each step should build on the result of the previous step.
99
98
100
99
- Map the tasks to durations in hours.
101
100
- Filter out everything that took less than two hours (i.e., remove from the collection)
102
-
- Multiply the each duration by a per-hour rate for billing (you can decide yourself what Maartje should earn per hour) and sum it all up.
101
+
- Multiply the each duration by a per-hour rate for billing (assume €20/hour) and sum it all up.
103
102
- Output a formatted Euro amount, rounded to Euro cents, e.g: `€ 12.34`.
104
103
- Choose variable and parameters names that most accurately describe their contents or purpose. When naming an array, use a plural form, e.g. `durations`. For a single item, use a singular form, e.g. `duration`. For details, see [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md).
105
104
- Don't forget to use `=>`.
106
105
107
-
## Step 3: ROVER
106
+
## Step 3: Testing your homework
107
+
108
+
We have provided _unit tests_ in this repo that allow you to verify that your homework produces the expected results.
109
+
110
+
> **Unit test**: A _unit test_ is a piece of code (usually a function) that invokes another piece of code and checks the correctness of some assumptions afterwards. If the assumptions turn out to be wrong, the unit test has failed. A 'unit' is a method or function.
111
+
>
112
+
> Adapted from: Roy Osherove (2009), The art of Unit Testing. Greenwich, CT: Manning.
113
+
114
+
At this point it is not important to understand how unit tests work. The only thing you need to know now is how to run the tests and how to determine whether your homework produces the correct results.
115
+
116
+
#### Installation
117
+
118
+
Before you can run the unit tests you need to install some additional software. You need to do this only once; there is no need to repeat it for the week 3 homework.
119
+
120
+
Open a terminal window. Make sure the current directory is the `JavaScript2` folder and type the following command:
121
+
122
+
```
123
+
npm install
124
+
```
125
+
126
+
This software installation might take a while.
127
+
128
+
#### Run the tests
129
+
130
+
Once the software installation has been completed, you can test your week 2 homework by typing this command in the terminal window:
131
+
132
+
```
133
+
npm run test2
134
+
```
135
+
136
+
You will see some output appearing in the console while the tests run. If all is well (no errors), the last couple of lines will look like this:
137
+
138
+
```
139
+
Test Suites: 2 passed, 2 total
140
+
Tests: 2 passed, 2 total
141
+
Snapshots: 0 total
142
+
Time: 1.849s
143
+
Ran all test suites matching /Week2\//i.
144
+
```
145
+
146
+
In case of unexpected results, say from _Maartjes work_ assignment, you might see something like this (you may need to scroll up a bit):
147
+
148
+
```
149
+
Test Suites: 1 failed, 1 passed, 2 total
150
+
Tests: 1 failed, 1 passed, 2 total
151
+
Snapshots: 0 total
152
+
Time: 2.255s
153
+
Ran all test suites matching /Week2\//i.
154
+
```
155
+
156
+
If that's the case, try and fix the error. When done, run the tests again: `npm run test2`
157
+
158
+
Repeat the previous step until all (= 2 in this case) tests pass.
159
+
160
+
## Step 4: ROVER
108
161
109
162
Finish up to chapter 7: JSON on [roverjs.com](http://roverjs.com/)!
110
163
111
-
## Step 4: **Some freeCodeCamp challenges:**
164
+
## Step 5: **Some freeCodeCamp challenges:**
112
165
113
166
_Deadline Saturday_
114
167
@@ -119,7 +172,7 @@ _Deadline Saturday_
119
172
3.[Use the map Method to Extract Data from an Array](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array)
120
173
121
174
122
-
## Step 5: Read before next lecture
175
+
## Step 6: Read before next lecture
123
176
124
177
_Deadline Sunday morning_
125
178
@@ -130,7 +183,7 @@ Go trough the reading material in the [README.md](/Week3/README.md) to prepare f
130
183
131
184
Go over your homework one last time:
132
185
133
-
- Does every file run without errors and with the correct results when you run them with Node?
186
+
- Does your homework pass all the unit tests?
134
187
- Does every file start with `'use strict';`?
135
188
- Have you used `const` and `let` and avoided `var`?
136
189
- Do the variable, function and argument names you created follow the [Naming Conventions](../../../../fundamentals/blob/master/fundamentals/naming_conventions.md)?
// please make sure you see why these calls are made before you start coding
85
85
```
86
86
87
-
> Note: The following assignments include some problems from _freeCodeCamp_. While we normally ask you to use more modern `const` and `let` keywords to declare variables, currently _freeCodeCamp_ does not give you that option and expects you to use the older `var` keyword.
87
+
> Note: The following assignments include some problems from _freeCodeCamp_. Note that some _freeCodeCamp_ examples still mention `var`. However you can safely replace them with `let`and `const` as appropriate.
>[Object Oriented Programming: Define a Constructor Function](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/define-a-constructor-function)<br>
100
+
[Object Oriented Programming: Use a Constructor to Create Objects](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects)
__Bonus__: Write a function takes this array `['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c']` and returns an array which only has unique values in it (so it removes the duplicate ones). Make it a 'smart' algorithm that could do it for every array (only strings/number). Try to make it as fast as possible!
161
162
162
163
163
-
## Step 5: Read before next lecture
164
+
## Step 5: Run the unit tests
165
+
166
+
(See the week 2 MAKEME for detailed instructions.)
167
+
168
+
To run the unit test for the week 3 homework, open a terminal window in the `JavaScript2` folder and type
169
+
170
+
```
171
+
npm run test3
172
+
```
173
+
174
+
In case of errors, try and fix them. When done, run the tests again: `npm run test3`
175
+
176
+
Repeat the previous step until all tests pass.
177
+
178
+
## Step 6: Read before next lecture
164
179
165
180
_Deadline Sunday morning_
166
181
@@ -171,7 +186,7 @@ Go trough the reading material in the [README.md](https://github.com/HackYourFut
171
186
172
187
Go over your homework one last time:
173
188
174
-
- Does every file run without errors and with the correct results when you run them with Node?
189
+
- Does your homework pass all the unit tests?
175
190
- Does every file start with `'use strict';`?
176
191
- Have you used `const` and `let` and avoided `var`?
177
192
- Do the variable, function and argument names you created follow the [Naming Conventions](../../../../fundamentals/blob/master/fundamentals/naming_conventions.md)?
0 commit comments