Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Week1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ In week one we will discuss the following topics:
"files.autoSave": "onFocusChange",
"prettier.printWidth": 100,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5"
"prettier.trailingComma": "all"
}
```

Expand Down
2 changes: 1 addition & 1 deletion Week1/homework/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
const bookTitles = [
// Replace with your own book titles
'harry_potter_chamber_secrets'
'harry_potter_chamber_secrets',
];

// Replace with your own code
Expand Down
24 changes: 12 additions & 12 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@
const monday = [
{
name: 'Write a summary HTML/CSS',
duration: 180
duration: 180,
},
{
name: 'Some web development',
duration: 120
duration: 120,
},
{
name: 'Fix homework for class10',
duration: 20
duration: 20,
},
{
name: 'Talk to a lot of people',
duration: 200
}
duration: 200,
},
];

const tuesday = [
{
name: 'Keep writing summary',
duration: 240
duration: 240,
},
{
name: 'Some more web development',
duration: 180
duration: 180,
},
{
name: 'Staring out the window',
duration: 10
duration: 10,
},
{
name: 'Talk to a lot of people',
duration: 200
duration: 200,
},
{
name: 'Look at application assignments new students',
duration: 40
}
duration: 40,
},
];

const maartjesTasks = monday.concat(tuesday);
Expand All @@ -61,5 +61,5 @@ console.log(`Maartje has earned €${'replace this string with the earnings roun
module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings
computeEarnings,
};
2 changes: 1 addition & 1 deletion Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ console.log(doubleOddNumbers(myNumbers));
// Do not change or remove anything below this line
module.exports = {
myNumbers,
doubleOddNumbers
doubleOddNumbers,
};
9 changes: 7 additions & 2 deletions Week3/MAKEME.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ const arr2d = [[1, 2], [3, 4], [5, 6]];

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

How would you print all the items of an array with 3 dimensions?
How about with _K_ dimensions?
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:

```js
const flattenedArr = [1, 2, 3, 4, 5, 6];
```

How about 3 dimensions? How about with _K_ dimensions?
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.)

**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.
Expand Down
8 changes: 4 additions & 4 deletions Week3/homework/step2-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

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

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

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

// Replace this comment and the next line with your code
Expand All @@ -43,5 +43,5 @@ console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 3));
module.exports = {
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile
repeatStringNumTimesWithDoWhile,
};
12 changes: 6 additions & 6 deletions Week3/homework/step2-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
const arr2d = [[1, 2], [3, 4], [5, 6]];
const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];

function printArray2d(arr) {
function flattenArray2d(arr) {
// Replace this comment and the next line with your code
console.log(arr);
}

function printArray3d(arr) {
function flattenArray3d(arr) {
// Replace this comment and the next line with your code
console.log(arr);
}

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

// Do not change or remove anything below this line
module.exports = {
printArray2d,
printArray3d
flattenArray2d,
flattenArray3d,
};
4 changes: 3 additions & 1 deletion Week3/test/console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

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

test(filename, () => {
console['log'] = jest.fn(storeLog);
console.log = jest.fn(storeLog);
// eslint-disable-next-line global-require
require('../homework/' + filename);
expect(outputData).toBe(expectedOutput);
});
Expand Down
2 changes: 1 addition & 1 deletion Week3/test/step2-3.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile
repeatStringNumTimesWithDoWhile,
} = require('../homework/step2-3');

describe('step2-3 with for-loop', () => {
Expand Down
25 changes: 9 additions & 16 deletions Week3/test/step2-6.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
/* eslint-disable no-return-assign, dot-notation */
const { printArray2d, printArray3d } = require('../homework/step2-6');
const { flattenArray2d, flattenArray3d } = require('../homework/step2-6');

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

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

describe('step2-6', () => {
let outputData;
const storeLog = (...inputs) => (outputData += inputs.join(' '));

test('printArray2d -> 1, 2, 3, 4, 5, 6', () => {
outputData = '';
console['log'] = jest.fn(storeLog);
printArray2d(arr2d);
expect(outputData).toBe(expected2d);
test('flattenArray2d -> [1, 2, 3, 4, 5, 6]', () => {
const result = flattenArray2d(arr2d);
expect(result).toEqual(expected2d);
});

test('printArray3d -> 1, 2, 3, 4, 5, 6, 7, 8', () => {
outputData = '';
console['log'] = jest.fn(storeLog);
printArray3d(arr3d);
expect(outputData).toBe(expected3d);
test('flattenArray3d -> [1, 2, 3, 4, 5, 6, 7, 8]', () => {
const result = flattenArray3d(arr3d);
expect(result).toEqual(expected3d);
});
});
4 changes: 2 additions & 2 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
printWidth: 100,
singleQuote: true,
trailingComma: 'none',
trailingComma: 'all',
bracketSpacing: true,
jsxBracketSameLine: false,
tabWidth: 2,
semi: true
semi: true,
};