Skip to content
Open
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
13 changes: 13 additions & 0 deletions .test-summary/TEST_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Test Summary

**Mentors**: For more information on how to review homework assignments, please refer to the [Review Guide](https://github.com/HackYourFuture/mentors/blob/main/assignment-support/review-guide.md).

### 1-JavaScript - Week3

| Exercise | Passed | Failed | ESLint |
|----------------------------|--------|--------|--------|
| ex1-doubleEvenNumbers.test | 1 | - | ✓ |
| ex2-mondaysWorth.test | 2 | - | ✓ |
| ex3-lemonAllergy.test | 3 | - | ✓ |
| ex4-observable | 3 | - | ✓ |
| ex5-wallet | 5 | - | ✓ |
11 changes: 3 additions & 8 deletions 1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ Let's rewrite it (or _refactor_ it, as experienced developers would call it):
------------------------------------------------------------------------------*/
// ! Function to be tested
function doubleEvenNumbers(numbers) {
// TODO rewrite the function body using `map` and `filter`.
const newNumbers = [];
for (let i = 0; i < numbers.length; i++) {
if (numbers[i] % 2 === 0) {
newNumbers.push(numbers[i] * 2);
}
}
return newNumbers;
return numbers
.filter(number => number % 2 === 0)
.map(number => number * 2);
Comment on lines +14 to +16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Clean and concise ⭐

}

// ! Unit test (using Jest)
Expand Down
7 changes: 5 additions & 2 deletions 1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ const mondayTasks = [

const hourlyRate = 25;

function computeEarnings(/* TODO parameter(s) go here */) {
// TODO complete this function
function computeEarnings(tasks, hourlyRate) {
const total = tasks
.map(task => task.duration / 60 * hourlyRate)
.reduce((sum, value) => sum + value, 0);
return `€${total.toFixed(2)}`;
Comment on lines +33 to +37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Clear naming for function parameters. Clean code and nice use of string templating.

}

// ! Unit tests (using Jest)
Expand Down
20 changes: 12 additions & 8 deletions 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,30 @@ const fruitBasket = [
];

// ! Function under test
function sanitizeFruitBasket(/* TODO parameter(s) go here */) {
// TODO complete this function

function sanitizeFruitBasket(basket, fruitToRemove) {
return basket.filter(fruit => fruit !== fruitToRemove);
}
Comment on lines +29 to 31

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way to go! Clear, easy-to-read function.



// ! Unit tests (using Jest)
describe('js-wk3-ex3-lemonAllergy', () => {
test('sanitizeFruitBasket should take two parameters', () => {
// TODO replace next line with your code
expect(false).toBe(true);

sanitizeFruitBasket.length;
expect(sanitizeFruitBasket.length).toBe(2);
Comment on lines +37 to +39

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});

test('sanitizeFruitBasket should not modify the original `fruitBasket` array', () => {
// Save the original contents of the fruit basket
const originalFruitBasketContents = [...fruitBasket];
// TODO replace next line with your code
expect(false).toBe(true);

sanitizeFruitBasket(fruitBasket, 'lemon');
expect(fruitBasket).toEqual(originalFruitBasketContents);
Comment on lines +45 to +47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});

test('sanitizeFruitBasket should return a new array that does not include the unwanted `lemon`', () => {
// TODO replace next line with your code
expect(false).toBe(true);
const newBasket = sanitizeFruitBasket(fruitBasket, 'lemon');
expect(newBasket.includes('lemon')).toBe(false);
Comment on lines +51 to +52

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export function createObservable() {
const subscribers = [];
return {
subscribe(subscriber) {
// TODO complete this function
subscribers.push(subscriber);
},
notify(message) {
// TODO complete this function
subscribers.forEach(subscriber => subscriber(message));
Comment on lines -19 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of the forEach method.

},
};
}
20 changes: 15 additions & 5 deletions 1-JavaScript/Week3/assignment/ex5-wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function createWallet(name, cash = 0) {
return amount;
}

function transferInto(wallet, amount) {
console.log(
`Transferring ${eurosFormatter.format(amount)} from ${name} to ${wallet.getName()}`
);
const withdrawnAmount = withdraw(amount);
wallet.deposit(withdrawnAmount);
}



Comment on lines +23 to +32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function repeated 2x?

function transferInto(wallet, amount) {
console.log(
`Transferring ${eurosFormatter.format(amount)} from ${name} to ${
Expand Down Expand Up @@ -75,7 +85,7 @@ const quiz = {
b: 'cash, name',
c: 'amount, this, wallet'
},
answer: '?',
answer: 'b',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
q2: {
question: 'What is in the Call Stack, from top to bottom?',
Expand All @@ -84,7 +94,7 @@ const quiz = {
b: 'anonymous, transferInto',
c: 'transferInto, anonymous'
},
answer: '?',
answer: 'c',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
q3: {
question: 'What tooltip appears when hovering over the third debug button?',
Expand All @@ -93,7 +103,7 @@ const quiz = {
b: 'Step out of current function',
c: 'Step'
},
answer: '?',
answer: 'a',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
q4: {
question: 'What is displayed in the console?',
Expand All @@ -102,7 +112,7 @@ const quiz = {
b: 'Transferring € 50,00 from Jack to undefined',
c: 'Transferring € 50,00 from Jack to Jane'
},
answer: '?',
answer: 'a',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
q5: {
question: 'The owner of the wallet with insufficient funds is:',
Expand All @@ -111,6 +121,6 @@ const quiz = {
b: 'Joe',
c: 'Jane'
},
answer: '?',
answer: 'c',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*** Unit Test Error Report ***

PASS 1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js
js-wk3-ex1-doubleEvenNumbers
✅ doubleEvenNumbers should take the even numbers and double them (1 ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.249 s, estimated 1 s
Ran all test suites matching /\/Users\/dashatkachenko\/Desktop\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex1-doubleEvenNumbers.test.js/i.
No linting errors detected.
No spelling errors detected.
14 changes: 14 additions & 0 deletions 1-JavaScript/Week3/test-reports/ex2-mondaysWorth.test.report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*** Unit Test Error Report ***

PASS 1-JavaScript/Week3/assignment/ex2-mondaysWorth.test.js
js-wk3-mondaysWorth
✅ computeEarnings should take two parameters
✅ computeEarnings should compute the earnings as a formatted Euro amount (1 ms)

Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 0.248 s, estimated 1 s
Ran all test suites matching /\/Users\/dashatkachenko\/Desktop\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex2-mondaysWorth.test.js/i.
No linting errors detected.
No spelling errors detected.
15 changes: 15 additions & 0 deletions 1-JavaScript/Week3/test-reports/ex3-lemonAllergy.test.report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*** Unit Test Error Report ***

PASS 1-JavaScript/Week3/assignment/ex3-lemonAllergy.test.js
js-wk3-ex3-lemonAllergy
✅ sanitizeFruitBasket should take two parameters
✅ sanitizeFruitBasket should not modify the original `fruitBasket` array
✅ sanitizeFruitBasket should return a new array that does not include the unwanted `lemon`

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.241 s, estimated 1 s
Ran all test suites matching /\/Users\/dashatkachenko\/Desktop\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex3-lemonAllergy.test.js/i.
No linting errors detected.
No spelling errors detected.
15 changes: 15 additions & 0 deletions 1-JavaScript/Week3/test-reports/ex4-observable.report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*** Unit Test Error Report ***

PASS 1-JavaScript/Week3/assignment/ex4-observable/ex4-observable.test.js
js-wk3-ex4-observable
✅ createObservable should exist and be a function (1 ms)
✅ createObservable should return an object with `subscribe` and a `notify` function properties
✅ observable should notify all subscribers of any notification

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.125 s, estimated 1 s
Ran all test suites matching /\/Users\/dashatkachenko\/Desktop\/Assignments-Cohort54\/1-JavaScript\/Week3\/assignment\/ex4-observable\/ex4-observable.test.js/i.
No linting errors detected.
No spelling errors detected.
17 changes: 17 additions & 0 deletions 1-JavaScript/Week3/test-reports/ex5-wallet.report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** Unit Test Error Report ***

PASS .dist/1-JavaScript/Week3/unit-tests/ex5-wallet.test.js
js-wk3-ex5-wallet
✅ q1: At line 24, which variables are in the scope marked Closure?
✅ q2: What is in the Call Stack, from top to bottom? (1 ms)
✅ q3: What tooltip appears when hovering over the third debug button?
✅ q4: What is displayed in the console?
✅ q5: The owner of the wallet with insufficient funds is?

Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 0.219 s, estimated 1 s
Ran all test suites matching /\/Users\/dashatkachenko\/Desktop\/Assignments-Cohort54\/.dist\/1-JavaScript\/Week3\/unit-tests\/ex5-wallet.test.js/i.
No linting errors detected.
No spelling errors detected.