Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32fdc45

Browse filesBrowse files
authored
Merge pull request HackYourFuture#268 from HackYourFuture/prep-class20
Prep class20
2 parents 44e27ed + 8e3d479 commit 32fdc45
Copy full SHA for 32fdc45

File tree

Expand file treeCollapse file tree

11 files changed

+47
-47
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

11 files changed

+47
-47
lines changed
Open diff view settings
Collapse file

‎Week1/README.md‎

Copy file name to clipboardExpand all lines: Week1/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ In week one we will discuss the following topics:
4646
"files.autoSave": "onFocusChange",
4747
"prettier.printWidth": 100,
4848
"prettier.singleQuote": true,
49-
"prettier.trailingComma": "es5"
49+
"prettier.trailingComma": "all"
5050
}
5151
```
5252

Collapse file

‎Week1/homework/app.js‎

Copy file name to clipboardExpand all lines: Week1/homework/app.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
const bookTitles = [
55
// Replace with your own book titles
6-
'harry_potter_chamber_secrets'
6+
'harry_potter_chamber_secrets',
77
];
88

99
// Replace with your own code
Collapse file

‎Week2/homework/maartjes-work.js‎

Copy file name to clipboardExpand all lines: Week2/homework/maartjes-work.js
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@
33
const monday = [
44
{
55
name: 'Write a summary HTML/CSS',
6-
duration: 180
6+
duration: 180,
77
},
88
{
99
name: 'Some web development',
10-
duration: 120
10+
duration: 120,
1111
},
1212
{
1313
name: 'Fix homework for class10',
14-
duration: 20
14+
duration: 20,
1515
},
1616
{
1717
name: 'Talk to a lot of people',
18-
duration: 200
19-
}
18+
duration: 200,
19+
},
2020
];
2121

2222
const tuesday = [
2323
{
2424
name: 'Keep writing summary',
25-
duration: 240
25+
duration: 240,
2626
},
2727
{
2828
name: 'Some more web development',
29-
duration: 180
29+
duration: 180,
3030
},
3131
{
3232
name: 'Staring out the window',
33-
duration: 10
33+
duration: 10,
3434
},
3535
{
3636
name: 'Talk to a lot of people',
37-
duration: 200
37+
duration: 200,
3838
},
3939
{
4040
name: 'Look at application assignments new students',
41-
duration: 40
42-
}
41+
duration: 40,
42+
},
4343
];
4444

4545
const maartjesTasks = monday.concat(tuesday);
@@ -61,5 +61,5 @@ console.log(`Maartje has earned €${'replace this string with the earnings roun
6161
module.exports = {
6262
maartjesTasks,
6363
maartjesHourlyRate,
64-
computeEarnings
64+
computeEarnings,
6565
};
Collapse file

‎Week2/homework/map-filter.js‎

Copy file name to clipboardExpand all lines: Week2/homework/map-filter.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ console.log(doubleOddNumbers(myNumbers));
1111
// Do not change or remove anything below this line
1212
module.exports = {
1313
myNumbers,
14-
doubleOddNumbers
14+
doubleOddNumbers,
1515
};
Collapse file

‎Week3/MAKEME.md‎

Copy file name to clipboardExpand all lines: Week3/MAKEME.md
+7-2Lines changed: 7 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ const arr2d = [[1, 2], [3, 4], [5, 6]];
112112

113113
(for math people you can think of this as a matrix)
114114

115-
How would you print all the items of an array with 3 dimensions?
116-
How about with _K_ dimensions?
115+
How would you flatten out all the items of an array with 2 dimensions into a one-dimensional array? Flattening out the `arr2d` array above would result in:
116+
117+
```js
118+
const flattenedArr = [1, 2, 3, 4, 5, 6];
119+
```
120+
121+
How about 3 dimensions? How about with _K_ dimensions?
117122
What if you didn't know how deep the array was nested? (You don't have to write code for this but think about it.)
118123

119124
**2.7** Here are two functions that look like they do the something similar but they print different results. Please explain what's going on here.
Collapse file

‎Week3/homework/step2-3.js‎

Copy file name to clipboardExpand all lines: Week3/homework/step2-3.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Use a 'for' loop
44
function repeatStringNumTimesWithFor(str, num) {
5-
// eslint-disable-next-line
5+
// eslint-disable-next-line prefer-const
66
let result = '';
77

88
// Replace this comment and the next line with your code
@@ -15,7 +15,7 @@ console.log('for', repeatStringNumTimesWithFor('abc', 3));
1515

1616
// Use a 'while' loop
1717
function repeatStringNumTimesWithWhile(str, num) {
18-
// eslint-disable-next-line
18+
// eslint-disable-next-line prefer-const
1919
let result = '';
2020

2121
// Replace this comment and the next line with your code
@@ -28,7 +28,7 @@ console.log('while', repeatStringNumTimesWithWhile('abc', 3));
2828

2929
// Use a 'do...while' loop
3030
function repeatStringNumTimesWithDoWhile(str, num) {
31-
// eslint-disable-next-line
31+
// eslint-disable-next-line prefer-const
3232
let result = '';
3333

3434
// Replace this comment and the next line with your code
@@ -43,5 +43,5 @@ console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 3));
4343
module.exports = {
4444
repeatStringNumTimesWithFor,
4545
repeatStringNumTimesWithWhile,
46-
repeatStringNumTimesWithDoWhile
46+
repeatStringNumTimesWithDoWhile,
4747
};
Collapse file

‎Week3/homework/step2-6.js‎

Copy file name to clipboardExpand all lines: Week3/homework/step2-6.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
const arr2d = [[1, 2], [3, 4], [5, 6]];
44
const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
55

6-
function printArray2d(arr) {
6+
function flattenArray2d(arr) {
77
// Replace this comment and the next line with your code
88
console.log(arr);
99
}
1010

11-
function printArray3d(arr) {
11+
function flattenArray3d(arr) {
1212
// Replace this comment and the next line with your code
1313
console.log(arr);
1414
}
1515

16-
printArray2d(arr2d);
17-
printArray3d(arr3d);
16+
console.log(flattenArray2d(arr2d)); // -> [1, 2, 3, 4, 5, 6]
17+
console.log(flattenArray3d(arr3d)); // -> [1, 2, 3, 4, 5, 6, 7, 8]
1818

1919
// Do not change or remove anything below this line
2020
module.exports = {
21-
printArray2d,
22-
printArray3d
21+
flattenArray2d,
22+
flattenArray3d,
2323
};
Collapse file

‎Week3/test/console-test.js‎

Copy file name to clipboardExpand all lines: Week3/test/console-test.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
function consoleTest(filename, expectedOutput) {
44
let outputData = '';
5+
// eslint-disable-next-line no-return-assign
56
const storeLog = (...inputs) => (outputData += inputs.join(' '));
67

78
test(filename, () => {
8-
console['log'] = jest.fn(storeLog);
9+
console.log = jest.fn(storeLog);
10+
// eslint-disable-next-line global-require
911
require('../homework/' + filename);
1012
expect(outputData).toBe(expectedOutput);
1113
});
Collapse file

‎Week3/test/step2-3.test.js‎

Copy file name to clipboardExpand all lines: Week3/test/step2-3.test.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {
22
repeatStringNumTimesWithFor,
33
repeatStringNumTimesWithWhile,
4-
repeatStringNumTimesWithDoWhile
4+
repeatStringNumTimesWithDoWhile,
55
} = require('../homework/step2-3');
66

77
describe('step2-3 with for-loop', () => {
Collapse file

‎Week3/test/step2-6.test.js‎

Copy file name to clipboard
+9-16Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
/* eslint-disable no-return-assign, dot-notation */
2-
const { printArray2d, printArray3d } = require('../homework/step2-6');
2+
const { flattenArray2d, flattenArray3d } = require('../homework/step2-6');
33

44
const arr2d = [[1, 2], [3, 4], [5, 6]];
5-
const expected2d = [1, 2, 3, 4, 5, 6].join('');
5+
const expected2d = [1, 2, 3, 4, 5, 6];
66

77
const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
8-
const expected3d = [1, 2, 3, 4, 5, 6, 7, 8].join('');
8+
const expected3d = [1, 2, 3, 4, 5, 6, 7, 8];
99

1010
describe('step2-6', () => {
11-
let outputData;
12-
const storeLog = (...inputs) => (outputData += inputs.join(' '));
13-
14-
test('printArray2d -> 1, 2, 3, 4, 5, 6', () => {
15-
outputData = '';
16-
console['log'] = jest.fn(storeLog);
17-
printArray2d(arr2d);
18-
expect(outputData).toBe(expected2d);
11+
test('flattenArray2d -> [1, 2, 3, 4, 5, 6]', () => {
12+
const result = flattenArray2d(arr2d);
13+
expect(result).toEqual(expected2d);
1914
});
2015

21-
test('printArray3d -> 1, 2, 3, 4, 5, 6, 7, 8', () => {
22-
outputData = '';
23-
console['log'] = jest.fn(storeLog);
24-
printArray3d(arr3d);
25-
expect(outputData).toBe(expected3d);
16+
test('flattenArray3d -> [1, 2, 3, 4, 5, 6, 7, 8]', () => {
17+
const result = flattenArray3d(arr3d);
18+
expect(result).toEqual(expected3d);
2619
});
2720
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.