-
Notifications
You must be signed in to change notification settings - Fork 17
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
Konjit-w1-UsingAPIs #52
base: main
Are you sure you want to change the base?
Conversation
Made the `is2Digit` function more readable.
export const getAnonName = (firstName) => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (!firstName) { |
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.
Nice solution. I love that you handle the rejection (fail-first) first.
} | ||
|
||
const is2Digit = (num) => num >= 10 && num <= 99; |
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.
Nice that you try to separate this into a function. Well done
.catch((error) => { | ||
console.log(error.message); | ||
}) | ||
.finally(() => { |
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 adding .finally()
to ensure cleanup (logging "Roll finished") is executed regardless of whether the Promise resolves or rejects.
const dice = [1, 2, 3, 4, 5]; | ||
return rollDie(1); | ||
const dicePromises = dice.map(() => rollDie()); | ||
return Promise.all(dicePromises); |
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
@@ -17,12 +17,23 @@ import { rollDie } from '../../helpers/pokerDiceRoller.js'; | |||
export function rollDice() { | |||
const results = []; | |||
|
|||
// TODO: expand the chain to include five dice | |||
return rollDie(1) | |||
.then((value) => { |
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, this works as expected.
But if you noticed, we are repeating these two codes from line 22 to 39:
results.push(value);
return rollDie(4);
We can prevent this with a Software engineering principle called "DRY Principle" by putting both as a function and use the function when needed. "Don't Repeat Yourself" (DRY) is a software development principle that helps us to avoid duplicating code. If you aren't aware of it, you can Google Search.
|
||
### 3-UsingAPIs - Week1 | ||
|
||
| Exercise | Passed | Failed | ESLint | |
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.
@konjit Great job completing week 1 assignment. Kudos!!! I will Approve it now.
Completed assignment for Week 1 of UsingAPIs.