-
Notifications
You must be signed in to change notification settings - Fork 7
Alaa_Nasher-w3-JavaScript #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | - | ✓ | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| const { duration } = require('moment/moment'); | ||
|
|
||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is being used in the required task. If not, please delete it. |
||
| /*------------------------------------------------------------------------------ | ||
| Full description atL https://github.com/HackYourFuture/Assignments/tree/main/1-JavaScript/Week4#exercise-2-whats-your-monday-worth | ||
|
|
||
|
|
@@ -30,10 +32,14 @@ const mondayTasks = [ | |
|
|
||
| const hourlyRate = 25; | ||
|
|
||
| function computeEarnings(/* TODO parameter(s) go here */) { | ||
| function computeEarnings(tasks, rate /* TODO parameter(s) go here */) { | ||
| // TODO complete this function | ||
| const hourlyRate = tasks | ||
| .map((task) => (task.duration / 60) * rate) | ||
| .reduce((sum, num) => sum + num); | ||
| return `€${hourlyRate.toFixed(2)}`; | ||
|
Comment on lines
+35
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fantastic! Shows good understanding of using map() and reduce methods and string templating. |
||
| } | ||
|
|
||
| //console.log(computeEarnings(mondayTasks, hourlyRate)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great for testing, but when no longer needed, it is a great practice to remove it from the codebase. |
||
| // ! Unit tests (using Jest) | ||
| describe('js-wk3-mondaysWorth', () => { | ||
| test('computeEarnings should take two parameters', () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,26 +25,29 @@ const fruitBasket = [ | |
| ]; | ||
|
|
||
| // ! Function under test | ||
| function sanitizeFruitBasket(/* TODO parameter(s) go here */) { | ||
| function sanitizeFruitBasket(fruit, name) { | ||
| // TODO complete this function | ||
| return fruit.filter((ele) => ele !== name); | ||
| } | ||
|
Comment on lines
+28
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job using the filter method. |
||
|
|
||
| // ! 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); | ||
| expect(sanitizeFruitBasket.length).toBe(2); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, 'banana'); | ||
| expect(fruitBasket).toEqual(originalFruitBasketContents); | ||
| // expect(false).toBe(true); | ||
|
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 modifiedFruitBasket = ['apple', 'grapefruit', 'banana', 'watermelon']; | ||
| const result = sanitizeFruitBasket(fruitBasket, 'lemon'); | ||
| expect(result).toEqual(modifiedFruitBasket); | ||
|
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,11 @@ export function createObservable() { | |
| return { | ||
| subscribe(subscriber) { | ||
| // TODO complete this function | ||
| return subscribers.push(subscriber); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }, | ||
| notify(message) { | ||
| // TODO complete this function | ||
| return subscribers.map((func) => func(message)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }, | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,7 @@ function createWallet(name, cash = 0) { | |
|
|
||
| function transferInto(wallet, amount) { | ||
| console.log( | ||
| `Transferring ${eurosFormatter.format(amount)} from ${name} to ${ | ||
| wallet.name | ||
| }` | ||
| `Transferring ${eurosFormatter.format(amount)} from ${name} to ${wallet.getName()}` | ||
| ); | ||
| const withdrawnAmount = withdraw(amount); | ||
| wallet.deposit(withdrawnAmount); | ||
|
|
@@ -75,7 +73,7 @@ const quiz = { | |
| b: 'cash, name', | ||
| c: 'amount, this, wallet' | ||
| }, | ||
| answer: '?', | ||
| answer: 'b', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }, | ||
| q2: { | ||
| question: 'What is in the Call Stack, from top to bottom?', | ||
|
|
@@ -84,7 +82,7 @@ const quiz = { | |
| b: 'anonymous, transferInto', | ||
| c: 'transferInto, anonymous' | ||
| }, | ||
| answer: '?', | ||
| answer: 'c', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :+1 |
||
| }, | ||
| q3: { | ||
| question: 'What tooltip appears when hovering over the third debug button?', | ||
|
|
@@ -93,7 +91,7 @@ const quiz = { | |
| b: 'Step out of current function', | ||
| c: 'Step' | ||
| }, | ||
| answer: '?', | ||
| answer: 'a', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }, | ||
| q4: { | ||
| question: 'What is displayed in the console?', | ||
|
|
@@ -102,7 +100,7 @@ const quiz = { | |
| b: 'Transferring € 50,00 from Jack to undefined', | ||
| c: 'Transferring € 50,00 from Jack to Jane' | ||
| }, | ||
| answer: '?', | ||
| answer: 'a', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }, | ||
| q5: { | ||
| question: 'The owner of the wallet with insufficient funds is:', | ||
|
|
@@ -111,6 +109,6 @@ const quiz = { | |
| b: 'Joe', | ||
| c: 'Jane' | ||
| }, | ||
| answer: '?', | ||
| answer: 'c', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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,18 @@ | ||
| *** 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 (2 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 1 passed, 1 total | ||
| Snapshots: 0 total | ||
| Time: 0.411 s, estimated 1 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/1-JavaScript\/Week3\/assignment\/ex1-doubleEvenNumbers.test.js/i. | ||
| No linting errors detected. | ||
|
|
||
|
|
||
| *** Spell Checker Report *** | ||
|
|
||
| 1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js:15:13 - Unknown word (Mumbers) | ||
| 1-JavaScript/Week3/assignment/ex1-doubleEvenNumbers.test.js:25:14 - Unknown word (Mumbers) |
| 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 (3 ms) | ||
| ✅ 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.879 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/1-JavaScript\/Week3\/assignment\/ex2-mondaysWorth.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
| 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 (2 ms) | ||
| ✅ sanitizeFruitBasket should not modify the original `fruitBasket` array (1 ms) | ||
| ✅ 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.472 s, estimated 1 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/1-JavaScript\/Week3\/assignment\/ex3-lemonAllergy.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
| 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 (2 ms) | ||
| ✅ createObservable should return an object with `subscribe` and a `notify` function properties (1 ms) | ||
| ✅ observable should notify all subscribers of any notification (2 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 3 passed, 3 total | ||
| Snapshots: 0 total | ||
| Time: 0.515 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/1-JavaScript\/Week3\/assignment\/ex4-observable\/ex4-observable.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
| 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? (2 ms) | ||
| ✅ q2: What is in the Call Stack, from top to bottom? | ||
| ✅ q3: What tooltip appears when hovering over the third debug button? (1 ms) | ||
| ✅ 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.558 s, estimated 1 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/1-JavaScript\/Week3\/unit-tests\/ex5-wallet.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
Some minor suggestions:
Overall a great effort. Good understanding of how to use array methods filter() and map().