forked from HackYourFuture/Assignments
-
Notifications
You must be signed in to change notification settings - Fork 4
Alaa nasher w1 using ap is #14
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
Open
Alaa2019-ml
wants to merge
9
commits into
HackYourAssignment:main
Choose a base branch
from
Alaa2019-ml:Alaa_Nasher-w1-UsingAPIs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2cbd8e5
Update README.md changed Assignment-CohortXX to JavaScript-CohortXX
Ro-P 42dbeb1
Add the answer code to ex1-johnWho.js
Alaa2019-ml 1c52c1e
Add the answer code to ex2
Alaa2019-ml c771d32
Add the answer code to ex3
Alaa2019-ml a624e85
Add the answer code to ex4 and ex5
Alaa2019-ml f0b8748
Add the explanation comment to ex4
Alaa2019-ml 2f4a92a
Remove extra spaces
Alaa2019-ml ef5d411
Test ex1
Alaa2019-ml 2b40000
Extend the explanatory comment in ex4
Alaa2019-ml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). | ||
|
|
||
| ### 3-UsingAPIs - Week1 | ||
|
|
||
| | Exercise | Passed | Failed | ESLint | | ||
| |-----------------------|--------|--------|--------| | ||
| | ex1-johnWho | 9 | - | ✓ | | ||
| | ex2-checkDoubleDigits | 11 | - | ✓ | | ||
| | ex3-rollDie | 7 | - | ✓ | | ||
| | ex4-pokerDiceAll | 7 | - | ✓ | | ||
| | ex5-pokerDiceChain | 5 | - | ✓ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,13 @@ exercise file. | |
| import { rollDie } from '../../helpers/pokerDiceRoller.js'; | ||
|
|
||
| export function rollDice() { | ||
| // TODO Refactor this function | ||
| const dice = [1, 2, 3, 4, 5]; | ||
| return rollDie(1); | ||
|
|
||
| return Promise.all( | ||
| dice.map((ele) => { | ||
| return rollDie(ele); // rollDie() returns a promise | ||
| }) | ||
| ); | ||
dardecena marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| function main() { | ||
|
|
@@ -43,4 +47,4 @@ if (process.env.NODE_ENV !== 'test') { | |
| main(); | ||
| } | ||
|
|
||
| // TODO Replace this comment by your explanation that was asked for in the assignment description. | ||
| // The remaining dice continue rolling because reject will only mark the promise as rejected but does not stop the execution of the code inside the function rolldie().To solve that we can use the return keyword right after reject(). In addition, after rejection, the function still schedules the next roll using setTimeout, so the die keeps rolling and logging updates even though its promise has already been rejected. This happens because promises in javaScript are not cancelable by default - once async operations like setTimeout are started they continue running unless explicitely stopped. Therefore each die runs independently, even if one promise is rejected, the other dice will continue their own rolls. | ||
|
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. 👍 |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| *** Unit Test Error Report *** | ||
|
|
||
| PASS .dist/3-UsingAPIs/Week1/unit-tests/ex1-johnWho.test.js | ||
| api-wk1-ex1-johnWho | ||
| ✅ should exist and be executable (3 ms) | ||
| ✅ should have all TODO comments removed (1 ms) | ||
| ✅ `getAnonName` should not contain unneeded console.log calls (1 ms) | ||
| ✅ should call `new Promise()` | ||
| ✅ should take a single argument | ||
| ✅ `resolve()` should be called with a one argument | ||
| ✅ `reject()` should be called with a one argument | ||
| ✅ should resolve when called with a string argument (2 ms) | ||
| ✅ should reject with an Error object when called without an argument (1 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 9 passed, 9 total | ||
| Snapshots: 0 total | ||
| Time: 1.118 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/3-UsingAPIs\/Week1\/unit-tests\/ex1-johnWho.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
23 changes: 23 additions & 0 deletions
23
3-UsingAPIs/Week1/test-reports/ex2-checkDoubleDigits.report.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| *** Unit Test Error Report *** | ||
|
|
||
| PASS .dist/3-UsingAPIs/Week1/unit-tests/ex2-checkDoubleDigits.test.js | ||
| api-wk1-ex2-checkDoubleDigits | ||
| ✅ should exist and be executable (2 ms) | ||
| ✅ should have all TODO comments removed (1 ms) | ||
| ✅ `checkDoubleDigits` should not contain unneeded console.log calls (1 ms) | ||
| ✅ should call new Promise() | ||
| ✅ `resolve()` should be called with a one argument (1 ms) | ||
| ✅ `reject()` should be called with a one argument | ||
| ✅ should be a function that takes a single argument (1 ms) | ||
| ✅ (9) should return a rejected promise with an Error object (1 ms) | ||
| ✅ (10) should return a promise that resolves to "This is a double digit number!" (1 ms) | ||
| ✅ (99) should return a promise that resolves to "This is a double digit number!" | ||
| ✅ (100) should return a rejected promise with an Error object | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 11 passed, 11 total | ||
| Snapshots: 0 total | ||
| Time: 0.598 s, estimated 1 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/3-UsingAPIs\/Week1\/unit-tests\/ex2-checkDoubleDigits.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| *** Unit Test Error Report *** | ||
|
|
||
| PASS .dist/3-UsingAPIs/Week1/unit-tests/ex3-rollDie.test.js | ||
| api-wk1-ex3-rollDie | ||
| ✅ should exist and be executable (2 ms) | ||
| ✅ should have all TODO comments removed (1 ms) | ||
| ✅ should call `new Promise()` (1 ms) | ||
| ✅ `resolve()` should be called with a one argument | ||
| ✅ `reject()` should be called with a one argument (1 ms) | ||
| ✅ should resolve when the die settles successfully (2 ms) | ||
| ✅ should reject with an Error when the die rolls off the table (1 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 7 passed, 7 total | ||
| Snapshots: 0 total | ||
| Time: 1.031 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/3-UsingAPIs\/Week1\/unit-tests\/ex3-rollDie.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
24 changes: 24 additions & 0 deletions
24
3-UsingAPIs/Week1/test-reports/ex4-pokerDiceAll.report.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| *** Unit Test Error Report *** | ||
|
|
||
| PASS .dist/3-UsingAPIs/Week1/unit-tests/ex4-pokerDiceAll.test.js | ||
| api-wk1-ex4-pokerDiceAll | ||
| ✅ should exist and be executable (4 ms) | ||
| ✅ should have all TODO comments removed | ||
| ✅ `rollDice` should not contain unneeded console.log calls (1 ms) | ||
| ✅ should use `dice.map()` (1 ms) | ||
| ✅ should use `Promise.all()` | ||
| ✅ should resolve when all dice settle successfully (11 ms) | ||
| ✅ should reject with an Error when a die rolls off the table (29 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 7 passed, 7 total | ||
| Snapshots: 0 total | ||
| Time: 1.14 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/3-UsingAPIs\/Week1\/unit-tests\/ex4-pokerDiceAll.test.js/i. | ||
| No linting errors detected. | ||
|
|
||
|
|
||
| *** Spell Checker Report *** | ||
|
|
||
| 3-UsingAPIs/Week1/assignment/ex4-pokerDiceAll.js:50:158 - Unknown word (rolldie) | ||
| 3-UsingAPIs/Week1/assignment/ex4-pokerDiceAll.js:50:576 - Unknown word (explicitely) |
17 changes: 17 additions & 0 deletions
17
3-UsingAPIs/Week1/test-reports/ex5-pokerDiceChain.report.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| *** Unit Test Error Report *** | ||
|
|
||
| PASS .dist/3-UsingAPIs/Week1/unit-tests/ex5-pokerDiceChain.test.js | ||
| api-wk1-ex5-pokerDiceChain | ||
| ✅ should exist and be executable (2 ms) | ||
| ✅ should have all TODO comments removed | ||
| ✅ `rollDice` should not contain unneeded console.log calls (1 ms) | ||
| ✅ should resolve when all dice settle successfully (21 ms) | ||
| ✅ should reject with an Error when a die rolls off the table (29 ms) | ||
|
|
||
| Test Suites: 1 passed, 1 total | ||
| Tests: 5 passed, 5 total | ||
| Snapshots: 0 total | ||
| Time: 0.493 s, estimated 1 s | ||
| Ran all test suites matching /\/Users\/Alaa\/Desktop\/JavaScript-Cohort54\/.dist\/3-UsingAPIs\/Week1\/unit-tests\/ex5-pokerDiceChain.test.js/i. | ||
| No linting errors detected. | ||
| No spelling errors detected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.